GetMakesForManufacturerAndYear
async function GetMakesForManufacturerAndYear(
manufacturer: string | number,
params: {
year: string | number
},
doFetch?: boolean
): Promise<NhtsaResponse<GetMakesForManufacturerAndYearResults> | string>
💡 More In Depth
See: Package Reference
Description
GetMakesForManufacturerAndYear
returns all the Makes in the vPIC dataset for a specified manufacturer
, and whose "Year From" and "Year To" range cover the specified year
. Multiple results are returned in case of multiple matches.
manufacturer
name can be a partial name, or a full name for more specificity, e.g. "988", "honda", "HONDA OF CANADA MFG., INC.", etc.
- If supplied
manufacturer
is a number - method will do exact match on Manufacturer's Id. - If supplied
manufacturer
is a string - it will look for manufacturers whose name is LIKE the provided name. It accepts a partial manufacturer name as an input.
params.year
must be a number > 2016, years prior to 2016 are not supported according to the NHTSA API. During testing it was found that the API still returns data for years prior to 2016.
❗ Required Parameters
Both manufacturer
and params.year
are required.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
manufacturer | string | number | undefined | Manufacturer Name (string) or Manufacturer ID (number) |
params | Object | undefined | Object of Query Search names and values to append to the URL as a query string |
params.year | string | number | undefined | Model year of the vehicle - Number, >= 2016 |
doFetch? | boolean | true | Whether to fetch the data or just return the URL (default: true ) |
📝 NOTE
Any params
that are not listed in the table above will be ignored.
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 GetMakeForManufacturerResults objects in the Results
key.
=> Promise<NhtsaResponse<GetMakesForManufacturerAndYearResults>>
type NhtsaResponse<GetMakesForManufacturerAndYearResults> = {
Count: number
Message: string
Results: Array<GetMakesForManufacturerAndYearResults>
SearchCriteria: string
}
🔍 Click to Show Full Example Response
// Using GetMakeForManufacturer('honda')
const exampleResponse = {
Count: 3,
Message: 'Response returned successfully',
Results: [
{
MakeId: 482,
MakeName: 'VOLKSWAGEN',
MfrId: 1148,
MfrName: 'VOLKSWAGEN AG',
},
{
MakeId: 482,
MakeName: 'VOLKSWAGEN',
MfrId: 16478,
MfrName: 'VOLKSWAGEN DE MEXICO SA DE CV',
},
{
MakeId: 482,
MakeName: 'VOLKSWAGEN',
MfrId: 1147,
MfrName: 'VOLKSWAGEN GROUP OF AMERICA, INC.',
},
],
SearchCriteria: 'Manufacturer : volks, Year: 2020',
}
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/GetMakesForManufacturerAndYear/volks?year=2020&format=json'
💡 See: BYOF - Bring Your Own Fetch
Type - GetMakesForManufacturerAndYearResults
type GetMakesForManufacturerAndYearResults = {
MakeId: number
MakeName: string
MfrId: number
MfrName: string
}
Ƭ GetMakesForManufacturerAndYearResults: Object
Objects returned in the Results
array of GetMakesForManufacturerAndYear
endpoint response.
Examples
Examples 1-2:
Fetches data from VPIC API
Returns:
=> Promise<NhtsaResponse<GetMakesForManufacturerAndYearResults>>
Example 1: Get Makes for Manufacturer Name and Year
import { GetMakesForManufacturerAndYear } from '@shaggytools/nhtsa-api-wrapper'
const response = await GetMakesForManufacturerAndYear('volks', { year: 2020 })
Example 2: Get Makes for Manufacturer ID and Year
import { GetMakesForManufacturerAndYear } from '@shaggytools/nhtsa-api-wrapper'
const response = await GetMakesForManufacturerAndYear(1148, { year: 2020 })
Examples 3-4:
Does NOT fetch data from VPIC API
Returns:
=> Promise<string>
Example 3: Get Makes for Manufacturer Name and Year with doFetch = false
import { GetMakesForManufacturerAndYear } from '@shaggytools/nhtsa-api-wrapper'
const url = await GetMakesForManufacturerAndYear('volks', { year: 2020 }, false)
// url = 'https://vpic.nhtsa.dot.gov/api/vehicles/GetMakesForManufacturerAndYear/volks?year=2020&format=json'
Example 4: Example 1: Get Makes for Manufacturer ID and Year with doFetch = false
import { GetMakesForManufacturerAndYear } from '@shaggytools/nhtsa-api-wrapper'
const url = await GetMakesForManufacturerAndYear(1148, { year: 2020 }, false)
// url = 'https://vpic.nhtsa.dot.gov/api/vehicles/GetMakesForManufacturerAndYear/1148?year=2020&format=json'