GetModelsForMake
async function GetModelsForMake(
makeName: string,
doFetch?: boolean
): Promise<NhtsaResponse<GetModelsForMakeResults> | string>
💡 More In Depth
See: Package Reference
Description
GetModelsForMake
returns the Models in the vPIC dataset for a specified makeName
whose Name is LIKE the Make in vPIC Dataset.
makeName
can be a partial, or a full for more specificity, e.g., "Harley", "Harley Davidson", etc.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
makeName | string | undefined | Vehicle make 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 GetManufacturerDetailsResults objects in the Results
key.
=> Promise<NhtsaResponse<GetModelsForMakeResults>>
type NhtsaResponse<GetModelsForMakeResults> = {
Count: number
Message: string
Results: Array<GetModelsForMakeResults>
SearchCriteria: string
}
🔍 Click to Show Full Example Response
// Using GetMakesForVehicleType('truck') - truncated for brevity
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:audi',
}
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/GetModelsForMake/audi?format=json'
💡 See: BYOF - Bring Your Own Fetch
Type - GetModelsForMakeResults
type GetModelsForMakeResults = {
Make_ID: number
Make_Name: string
Model_ID: number
Model_Name: string
}
Ƭ GetModelsForMakeResults: Object
Objects returned in the Results
array of GetModelsForMake
endpoint response.
Examples
Example 1:
Fetches data from VPIC API
Returns:
=> Promise<NhtsaResponse<GetModelsForMakeResults>>
Example 1: Get Models for Make
import { GetModelsForMake } from '@shaggytools/nhtsa-api-wrapper'
const response = await GetModelsForMake('audi')
Example 2:
Does NOT fetch data from VPIC API
Returns:
=> Promise<string>
Example 2: Get Models for Make and doFetch = false
import { GetModelsForMake } from '@shaggytools/nhtsa-api-wrapper'
const url = await GetModelsForMake('audi', false)
// url: 'https://vpic.nhtsa.dot.gov/api/vehicles/getmodelsformake/audi?format=json'