GetModelsForMakeId
async function GetModelsForMakeId(
makeId: string | number,
doFetch?: boolean
): Promise<NhtsaResponse<GetModelsForMakeIdResults> | string>
💡 More In Depth
See: Package Reference
Description
GetModelsForMakeId
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 GetModelsForMakeIdResults objects in the Results
key.
=> Promise<NhtsaResponse<GetModelsForMakeIdResults>>
type NhtsaResponse<GetModelsForMakeIdResults> = {
Count: number
Message: string
Results: Array<GetModelsForMakeIdResults>
SearchCriteria: string
}
🔍 Click to Show Full Example Response
// Using GetModelsForMakeId(582)
const exampleResponse = {
Count: 49,
Message: 'Response returned successfully',
Results: [
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3145,
Model_Name: 'TT',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3146,
Model_Name: 'A4',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3147,
Model_Name: 'S4',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3148,
Model_Name: 'A6',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3149,
Model_Name: 'RS6',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3150,
Model_Name: 'allroad',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3151,
Model_Name: 'A8',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3675,
Model_Name: 'RS4',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3676,
Model_Name: 'A3',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3677,
Model_Name: 'S6',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3678,
Model_Name: 'S8',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3679,
Model_Name: 'Q7',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3787,
Model_Name: 'A5',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3788,
Model_Name: 'S5',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3789,
Model_Name: 'R8',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3861,
Model_Name: 'TTS',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 3862,
Model_Name: 'Q5',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 4014,
Model_Name: 'RS5',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 4015,
Model_Name: 'A7',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 4016,
Model_Name: 'TT RS',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 4051,
Model_Name: 'Q3',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 4052,
Model_Name: 'SQ5',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 8056,
Model_Name: '90',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 8057,
Model_Name: '100',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 8058,
Model_Name: 'V8',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 8059,
Model_Name: 'Cabriolet',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 8173,
Model_Name: 'S3',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 8258,
Model_Name: 'S7',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 8685,
Model_Name: 'RS7',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 13759,
Model_Name: 'A4 allroad',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 14336,
Model_Name: '5000',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 14337,
Model_Name: '4000',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 14342,
Model_Name: '80',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 14343,
Model_Name: '200',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 14348,
Model_Name: 'Coupe',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 16783,
Model_Name: 'RS3',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 25317,
Model_Name: 'Q8',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 25874,
Model_Name: 'e-tron',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 27028,
Model_Name: 'A6 allroad',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 27029,
Model_Name: 'Q5 e',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 27122,
Model_Name: 'A8 e',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 27401,
Model_Name: 'SQ7',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 27402,
Model_Name: 'SQ8',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 27403,
Model_Name: 'RS Q8',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 27819,
Model_Name: 'e-tron Sportback',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 28998,
Model_Name: 'RS e-tron GT',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 29351,
Model_Name: 'Q4',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 29708,
Model_Name: 'A8 L',
},
{
Make_ID: 582,
Make_Name: 'AUDI',
Model_ID: 29994,
Model_Name: 'e-tron GT',
},
],
SearchCriteria: 'Make:582',
}
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/GetModelsForMakeId/582?format=json'
💡 See: BYOF - Bring Your Own Fetch
Type - GetModelsForMakeIdResults
type GetModelsForMakeIdResults = {
Make_ID: number
Make_Name: string
Model_ID: number
Model_Name: string
}
Ƭ GetModelsForMakeIdResults: Object
Objects returned in the Results
array of GetModelsForMakeId
endpoint response.
Examples
Example 1:
Fetches data from VPIC API
Returns:
=> Promise<NhtsaResponse<GetModelsForMakeIdResults>>
Example 1: Get Models for Make ID
import { GetModelsForMakeId } from '@shaggytools/nhtsa-api-wrapper'
const response = await GetModelsForMakeId(582)
Example 2:
Does NOT fetch data from VPIC API
Returns:
=> Promise<string>
Example 2: Get Models for Make ID and doFetch = false
import { GetModelsForMakeId } from '@shaggytools/nhtsa-api-wrapper'
const url = await GetModelsForMakeId(582, false)
// url: 'https://vpic.nhtsa.dot.gov/api/vehicles/GetModelsForMakeId/582?format=json'