GetVehicleTypesForMakeId
async function GetVehicleTypesForMakeId(
makeId: string | number,
doFetch?: boolean
): Promise<NhtsaResponse<GetVehicleTypesForMakeIdResults> | string>
💡 More In Depth
See: Package Reference
Description
GetVehicleTypesForMakeId
returns the Models in the vPIC dataset for a specified Make whose ID is equal to the makeID
in the vPIC Dataset.
You can get makeID
s via MAKE_ID
key in Results objects of the following endpoints:
GetAllMakes
endpointGetMakeForManufacturer
endpointGetModelsForMake
endpointGetModelsForMakeYear
endpoint
You can get makeID
s via MakeID
key in Results objects of the following endpoints:
DecodeVinValues
DecodeVinValuesBatch
You can get makeID
s via ValueId
key in Results objects of the following endpoints. One of the objects in the Results
array will contain both Variable: "Make"
and VariableId: 26
. The ValueId
key in that same object is the makeID
for use in this endpoint.
DecodeVin
DecodeVinExtended
Parameters
Name | Type | Default value | Description |
---|---|---|---|
makeId | string | number | undefined | Make ID to search |
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 GetVehicleTypesForMakeIdResults objects in the Results
key.
=> Promise<NhtsaResponse<GetVehicleTypesForMakeIdResults>>
type NhtsaResponse<GetVehicleTypesForMakeIdResults> = {
Count: number
Message: string
Results: Array<GetVehicleTypesForMakeIdResults>
SearchCriteria: string
}
🔍 Click to Show Full Example Response
// Using GetVehicleTypesForMakeId(449)
const exampleResponse = {
Count: 5,
Message: 'Response returned successfully',
Results: [
{
VehicleTypeId: 2,
VehicleTypeName: 'Passenger Car',
},
{
VehicleTypeId: 3,
VehicleTypeName: 'Truck ',
},
{
VehicleTypeId: 5,
VehicleTypeName: 'Bus',
},
{
VehicleTypeId: 7,
VehicleTypeName: 'Multipurpose Passenger Vehicle (MPV)',
},
{
VehicleTypeId: 10,
VehicleTypeName: 'Incomplete Vehicle',
},
],
SearchCriteria: 'Make ID: 449',
}
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/GetVehicleTypesForMakeId/449?format=json'
💡 See: BYOF - Bring Your Own Fetch
Type - GetVehicleTypesForMakeIdResults
type GetVehicleTypesForMakeIdResults = {
VehicleTypeId: number
VehicleTypeName: string
}
Ƭ GetVehicleTypesForMakeIdResults: Object
Objects returned in the Results
array of GetVehicleTypesForMakeId
endpoint response.
Examples
Example 1:
=> Promise<NhtsaResponse<GetVehicleTypesForMakeIdResults>>
- Fetches data from VPIC API
Example 1: Get Vehicle Types for Make ID
import { GetVehicleTypesForMakeId } from '@shaggytools/nhtsa-api-wrapper'
const response = await GetVehicleTypesForMakeId(449)
Example 2:
Does NOT fetch data from VPIC API
Returns:
=> Promise<string>
Example 2: Get Vehicle Types for Make ID and doFetch = false
import { GetVehicleTypesForMakeId } from '@shaggytools/nhtsa-api-wrapper'
const url = await GetVehicleTypesForMakeId(449, false)
// url: 'https://vpic.nhtsa.dot.gov/api/vehicles/GetVehicleTypesForMakeId/449?format=json'