Skip to content
On this page

GetVehicleTypesForMakeId


typescript
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 makeIDs via MAKE_ID key in Results objects of the following endpoints:

  • GetAllMakes endpoint
  • GetMakeForManufacturer endpoint
  • GetModelsForMake endpoint
  • GetModelsForMakeYear endpoint

You can get makeIDs via MakeID key in Results objects of the following endpoints:

  • DecodeVinValues
  • DecodeVinValuesBatch

You can get makeIDs 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

NameTypeDefault valueDescription
makeIdstring | numberundefinedMake ID to search
doFetch?booleantrueWhether to fetch the data or just return the URL (default: true)

📝 NOTE

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 GetVehicleTypesForMakeIdResults objects in the Results key.

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

typescript
=> Promise<string>

// ex: => 'https://vpic.nhtsa.dot.gov/api/vehicles/GetVehicleTypesForMakeId/449?format=json'

Type - GetVehicleTypesForMakeIdResults

ts
type GetVehicleTypesForMakeIdResults = {
  VehicleTypeId: number
  VehicleTypeName: string
}

Ƭ GetVehicleTypesForMakeIdResults: Object

Objects returned in the Results array of GetVehicleTypesForMakeId endpoint response.

Examples

Example 1:

typescript
=> Promise<NhtsaResponse<GetVehicleTypesForMakeIdResults>>
  • Fetches data from VPIC API

Example 1: Get Vehicle Types for Make ID

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

const response = await GetVehicleTypesForMakeId(449)

Example 2:

typescript
=> Promise<string>

Example 2: Get Vehicle Types for Make ID and doFetch = false

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

Released under the MIT License.