GetMakesForVehicleType
async function GetMakesForVehicleType(
typeName: string,
doFetch?: boolean
): Promise<NhtsaResponse<GetMakesForVehicleTypeResults> | string>
💡 More In Depth
See: Package Reference
Description
GetMakesForVehicleType
returns all the Makes in the vPIC dataset for a specified vehicle type (typeName
), whose name is LIKE the vehicle type name in vPIC Dataset.
typeName
can be a partial name, or a full name for more specificity, e.g., "Vehicle", "Moto", "Low Speed Vehicle", etc.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
typeName | string | undefined | A partial or full vehicle type name |
doFetch? | boolean | true | Whether to fetch the data or just return the URL (default: true ) |
📝 NOTE
Set doFetch
to false
if you want to fetch the data yourself.
- See BYOF - Bring Your Own Fetch for more info.
Returns
Returns a Promise that resolves to a NhtsaResponse object containing an array of GetMakesForVehicleTypeResults objects in the Results
key.
=> Promise<NhtsaResponse<GetMakesForVehicleTypeResults>>
type NhtsaResponse<GetMakesForVehicleTypeResults> = {
Count: number
Message: string
Results: Array<GetMakesForVehicleTypeResults>
SearchCriteria: string
}
🔍 Click to Show Full Example Response
// Using GetMakesForVehicleType('truck') - truncated for brevity
const exampleResponse = {
Count: 171,
Message: 'Response returned successfully',
Results: [
{
MakeId: 441,
MakeName: 'TESLA',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
MakeId: 448,
MakeName: 'TOYOTA',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
MakeId: 449,
MakeName: 'MERCEDES-BENZ',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
MakeId: 450,
MakeName: 'FREIGHTLINER',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
MakeId: 460,
MakeName: 'FORD',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
MakeId: 464,
MakeName: 'LINCOLN',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
MakeId: 465,
MakeName: 'MERCURY',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
MakeId: 467,
MakeName: 'CHEVROLET',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
MakeId: 469,
MakeName: 'CADILLAC',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
MakeId: 472,
MakeName: 'GMC',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
MakeId: 473,
MakeName: 'MAZDA',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
MakeId: 474,
MakeName: 'HONDA',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
MakeId: 475,
MakeName: 'ACURA',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
MakeId: 476,
MakeName: 'DODGE',
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
// ... 156 more items
],
SearchCriteria: 'Vehicle Type: truck',
}
If doFetch
is set to false
Returns a URL string that can be used to fetch the data, does not fetch the data internally.
=> Promise<string>
// ex: => 'https://vpic.nhtsa.dot.gov/api/vehicles/GetMakesForVehicleType/truck?format=json'
💡 See: BYOF - Bring Your Own Fetch
Type - GetMakesForVehicleTypeResults
type GetMakesForVehicleTypeResults = {
MakeId: number
MakeName: string
VehicleTypeId: number
VehicleTypeName: string
}
Ƭ GetMakesForVehicleTypeResults: Object
Objects returned in the Results
array of GetMakesForVehicleTypeResults
endpoint response.
Examples
Example 1:
Fetches data from VPIC API
Returns:
=> Promise<NhtsaResponse<GetMakesForVehicleTypeResults>>
Example 1: Get Makes for Vehicle Type
import { GetMakesForVehicleType } from '@shaggytools/nhtsa-api-wrapper'
const response = await GetMakesForVehicleType('truck')
Example 2:
Does NOT fetch data from VPIC API
Returns:
=> Promise<string>
Example 2: Get Makes for Vehicle Type with doFetch = false
import { GetMakesForVehicleType } from '@shaggytools/nhtsa-api-wrapper'
const url = await GetMakesForVehicleType('truck', false)
// url = 'https://vpic.nhtsa.dot.gov/api/vehicles/GetMakesForVehicleType/truck?format=json'