Skip to content
On this page

GetMakesForManufacturerAndYear


typescript
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

NameTypeDefault valueDescription
manufacturerstring | numberundefinedManufacturer Name (string) or Manufacturer ID (number)
paramsObjectundefinedObject of Query Search names and values to append to the URL as a query string
params.yearstring | numberundefinedModel year of the vehicle - Number, >= 2016
doFetch?booleantrueWhether 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.

Returns

Returns a Promise that resolves to a NhtsaResponse object containing an array of GetMakeForManufacturerResults objects in the Results key.

typescript
=> Promise<NhtsaResponse<GetMakesForManufacturerAndYearResults>>
typescript
type NhtsaResponse<GetMakesForManufacturerAndYearResults> = {
  Count: number
  Message: string
  Results: Array<GetMakesForManufacturerAndYearResults>
  SearchCriteria: string
}
🔍 Click to Show Full Example Response
ts
// 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.

typescript
=> Promise<string>

// ex: => 'https://vpic.nhtsa.dot.gov/api/vehicles/GetMakesForManufacturerAndYear/volks?year=2020&format=json'

Type - GetMakesForManufacturerAndYearResults

ts
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:

typescript
=> Promise<NhtsaResponse<GetMakesForManufacturerAndYearResults>>

Example 1: Get Makes for Manufacturer Name and Year

ts
import { GetMakesForManufacturerAndYear } from '@shaggytools/nhtsa-api-wrapper'

const response = await GetMakesForManufacturerAndYear('volks', { year: 2020 })

Example 2: Get Makes for Manufacturer ID and Year

ts
import { GetMakesForManufacturerAndYear } from '@shaggytools/nhtsa-api-wrapper'

const response = await GetMakesForManufacturerAndYear(1148, { year: 2020 })

Examples 3-4:

typescript
=> Promise<string>

Example 3: Get Makes for Manufacturer Name and Year with doFetch = false

ts
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

ts
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'

Released under the MIT License.