Skip to content
On this page

GetVehicleTypesForMake


typescript
async function GetVehicleTypesForMake(
  makeName: string,
  doFetch?: boolean
): Promise<NhtsaResponse<GetVehicleTypesForMakeResults> | string>

💡 More In Depth

See: Package Reference

Description

GetVehicleTypesForMake returns all the Vehicle Types in the vPIC dataset for a specified Make, whose name is LIKE the make name in the vPIC Dataset.

makeName can be a partial name, or a full name for more specificity, e.g., "Merc", "Mercedes Benz", etc.

Parameters

NameTypeDefault valueDescription
makeNamestringundefinedName of the vehicle make 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 GetVehicleTypesForMakeResults objects in the Results key.

typescript
=> Promise<NhtsaResponse<GetVehicleTypesForMakeResults>>
typescript
type NhtsaResponse<GetVehicleTypesForMakeResults> = {
  Count: number
  Message: string
  Results: Array<GetVehicleTypesForMakeResults>
  SearchCriteria: string
}
🔍 Click to Show Full Example Response
ts
// Using GetVehicleTypesForMake('merc')
const exampleResponse = {
  Count: 22,
  Message: 'Response returned successfully',
  Results: [
    {
      MakeId: 449,
      MakeName: 'MERCEDES-BENZ',
      VehicleTypeId: 2,
      VehicleTypeName: 'Passenger Car',
    },
    {
      MakeId: 449,
      MakeName: 'MERCEDES-BENZ',
      VehicleTypeId: 3,
      VehicleTypeName: 'Truck ',
    },
    {
      MakeId: 449,
      MakeName: 'MERCEDES-BENZ',
      VehicleTypeId: 5,
      VehicleTypeName: 'Bus',
    },
    {
      MakeId: 449,
      MakeName: 'MERCEDES-BENZ',
      VehicleTypeId: 7,
      VehicleTypeName: 'Multipurpose Passenger Vehicle (MPV)',
    },
    {
      MakeId: 449,
      MakeName: 'MERCEDES-BENZ',
      VehicleTypeId: 10,
      VehicleTypeName: 'Incomplete Vehicle',
    },
    {
      MakeId: 465,
      MakeName: 'MERCURY',
      VehicleTypeId: 2,
      VehicleTypeName: 'Passenger Car',
    },
    {
      MakeId: 465,
      MakeName: 'MERCURY',
      VehicleTypeId: 3,
      VehicleTypeName: 'Truck ',
    },
    {
      MakeId: 465,
      MakeName: 'MERCURY',
      VehicleTypeId: 7,
      VehicleTypeName: 'Multipurpose Passenger Vehicle (MPV)',
    },
    {
      MakeId: 465,
      MakeName: 'MERCURY',
      VehicleTypeId: 10,
      VehicleTypeName: 'Incomplete Vehicle',
    },
    {
      MakeId: 928,
      MakeName: 'FABRICACION Y COMERCIALIZACION PENA',
      VehicleTypeId: 6,
      VehicleTypeName: 'Trailer',
    },
    {
      MakeId: 945,
      MakeName: 'CAPSTONE COMMERCE',
      VehicleTypeId: 6,
      VehicleTypeName: 'Trailer',
    },
    {
      MakeId: 1820,
      MakeName: 'COMMERCIAL TRAILER',
      VehicleTypeId: 6,
      VehicleTypeName: 'Trailer',
    },
    {
      MakeId: 2350,
      MakeName: 'MERCH MOTORCYCLE CO.',
      VehicleTypeId: 1,
      VehicleTypeName: 'Motorcycle',
    },
    {
      MakeId: 2351,
      MakeName: "MERCHANT'S TRAILERS AND GRILLS",
      VehicleTypeId: 6,
      VehicleTypeName: 'Trailer',
    },
    {
      MakeId: 4977,
      MakeName: 'STRICK COMMERCIAL TRAILER',
      VehicleTypeId: 6,
      VehicleTypeName: 'Trailer',
    },
    {
      MakeId: 5416,
      MakeName: 'CA. COMMERCIAL TRAILER',
      VehicleTypeId: 6,
      VehicleTypeName: 'Trailer',
    },
    {
      MakeId: 5804,
      MakeName: 'COMMERCIAL STRUCTURES',
      VehicleTypeId: 6,
      VehicleTypeName: 'Trailer',
    },
    {
      MakeId: 6983,
      MakeName: 'J & T MERCHANDISE INC',
      VehicleTypeId: 6,
      VehicleTypeName: 'Trailer',
    },
    {
      MakeId: 7008,
      MakeName: 'COMMERCIAL MOBILE SYSTEMS',
      VehicleTypeId: 6,
      VehicleTypeName: 'Trailer',
    },
    {
      MakeId: 8306,
      MakeName: 'COMMERCIAL MANUFACTURING & INDUSTRIAL, CO.',
      VehicleTypeId: 6,
      VehicleTypeName: 'Trailer',
    },
    {
      MakeId: 8959,
      MakeName: 'BIVOUAC COMMERCIAL VEHICLES',
      VehicleTypeId: 6,
      VehicleTypeName: 'Trailer',
    },
    {
      MakeId: 9539,
      MakeName: 'COMMERCIAL VEHICLES CV',
      VehicleTypeId: 6,
      VehicleTypeName: 'Trailer',
    },
  ],
  SearchCriteria: 'Make: merc',
}

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/GetVehicleTypesForMake/merc?format=json'

Type - GetVehicleTypesForMakeResults

ts
type GetVehicleTypesForMakeResults = {
  MakeId: number
  MakeName: string
  VehicleTypeId: number
  VehicleTypeName: string
}

Ƭ GetVehicleTypesForMakeResults: Object

Objects returned in the Results array of GetVehicleTypesForMake endpoint response.

Examples

Example 1:

  • Fetches data from VPIC API

  • Returns:

typescript
=> Promise<NhtsaResponse<GetVehicleTypesForMakeResults>>

Example 1: Get Vehicle Types for Make

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

const response = await GetVehicleTypesForMake('merc')

Example 2:

typescript
=> Promise<string>

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

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

const url = await GetVehicleTypesForMake('merc', false)

// url: 'https://vpic.nhtsa.dot.gov/api/vehicles/GetVehicleTypesForMake/merc?format=json'

Released under the MIT License.