Skip to content
On this page

GetWMIsForManufacturer


typescript
async function GetWMIsForManufacturer(
  params: AtLeastOne<{
    manufacturer?: string | number
    vehicleType?: string | number
  }>,
  doFetch?: boolean
): Promise<NhtsaResponse<GetWMIsForManufacturerResults> | string>

💡 More In Depth

See: Package Reference

Description

GetWMIsForManufacturer provides information on the World Manufacturer Identifier (WMI) for a specified manufacturer. Only WMIs registered in vPICList are displayed. Multiple results are returned in case of multiple matches.

Both manufacturer and vehicleType are optional but at least one must be provided.

manufacturer can be a partial name, or a full name for more specificity, or WMI ID number, e.g., "Merc", "Mercedes Benz", 987, etc.

  • If manufacturer is a number - method will do exact match on Manufacturer's Id
  • If 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)

vehicleType can be a string or number, e.g., "car", 1, etc.

  • If vehicleType is a number - method will do exact match on VehicleType's Id
  • If vehicleType is a string - it will look for VehicleType whose name is LIKE the provided name (it accepts a partial VehicleType name as an input).

NOTE: For this endpoint, manufacturer is actually part of the path string, not a query param. We include manufacturer in params as it's easier to type the function args using the 'AtLeastOne' type if they are placed in the same object (params). This can cause confusion as it's not consistent with other endpoint methods where path string is the first arg, and the query params are the second arg.

Parameters

NameTypeDefault ValueDescription
paramsObjectundefinedObject of query search names and values to append to the URL as a query string.
params.manufacturer?string | numberundefinedManufacturer Name or ID, or WMI ID (required if !vehicleType)
params.vehicleType?string | numberundefinedOptional Vehicle Type search parameter (required if !manufacturer)
doFetchbooleantrueWhether 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 GetWMIsForManufacturerResults objects in the Results key.

typescript
=> Promise<NhtsaResponse<GetWMIsForManufacturerResults>>
typescript
type NhtsaResponse<GetWMIsForManufacturerResults> = {
  Count: number
  Message: string
  Results: Array<GetWMIsForManufacturerResults>
  SearchCriteria: string
}
🔍 Click to Show Full Example Response
ts
// Using GetWMIsForManufacturer(987, vehicleType: 2)
const exampleResponse = {
  Count: 2,
  Message: 'Response returned successfully',
  Results: [
    {
      Country: null,
      CreatedOn: '2015-03-26',
      DateAvailableToPublic: '2015-01-01',
      Id: 987,
      Name: 'HONDA MOTOR CO., LTD',
      UpdatedOn: '2015-06-04',
      VehicleType: 'Passenger Car',
      WMI: 'JHM',
    },
    {
      Country: null,
      CreatedOn: '2015-03-27',
      DateAvailableToPublic: '2015-01-01',
      Id: 987,
      Name: 'HONDA MOTOR CO., LTD',
      UpdatedOn: null,
      VehicleType: 'Passenger Car',
      WMI: 'JH4',
    },
  ],
  SearchCriteria: 'Manufacturer: 987 , VehicleType: 2',
}

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/GetVehicleVariableValuesList/battery%20type?format=json'

Type - GetWMIsForManufacturerResults

ts
type GetWMIsForManufacturerResults = {
  Country: string | null
  CreatedOn: string
  DateAvailableToPublic: string
  Id: number
  Name: string
  UpdatedOn: string
  VehicleType: string
  WMI: string
}

Ƭ GetWMIsForManufacturerResults: Object

Objects returned in the Results array of GetWMIsForManufacturer endpoint response.

Examples

Examples 1-3:

  • Fetches data from VPIC API

  • Returns:

typescript
=> Promise<NhtsaResponse<GetWMIsForManufacturerResults>>

Example 1: Get WMIs for Manufacturer

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

const response = await GetWMIsForManufacturer({ manufacturer: 'Mercedes Benz' })

Example 2: Get WMIs for Vehicle Type

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

const response = await GetWMIsForManufacturer({ vehicleType: 'car' })

Example 3: Get WMIs for Manufacturer and Vehicle Type

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

const response = await GetWMIsForManufacturer({
  manufacturer: 'honda',
  vehicleType: 'car',
})

Examples 4-6:

typescript
=> Promise<string>

Example 4: Get WMIs for Manufacturer and doFetch = false

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

const url = await GetWMIsForManufacturer({ manufacturer: 'honda' }, false)

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

Example 5: Get WMIs for Vehicle Type and doFetch = false

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

const url = await GetWMIsForManufacturer({ vehicleType: 'car' }, false)

// url: 'https://vpic.nhtsa.dot.gov/api/vehicles/GetWMIsForManufacturer?vehicleType=car&format=json'

Example 6: Get WMIs for Manufacturer and Vehicle Type and doFetch = false

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

const url = await GetWMIsForManufacturer(
  { manufacturer: 'honda', vehicleType: 'car' },
  false
)

// url: 'https://vpic.nhtsa.dot.gov/api/vehicles/GetWMIsForManufacturer/honda?vehicleType=car&format=json'

Released under the MIT License.