Skip to content
On this page

DecodeWMI


typescript
async function DecodeWMI(
  WMI: string,
  doFetch?: boolean
) => Promise<NhtsaResponse<DecodeWMIResults> | string>

💡 More In Depth

See: Package Reference

Description

DecodeWMI provides information on the World Manufacturer Identifier for a specific WMI code.

WMI may be provided as either 3 characters representing VIN position 1-3 or 6 characters representing VIN positions 1-3 & 12-14.

  • Examples: "JTD" "1T9131"

A list of WMI codes can be found here, but keep in mind that not all of the listed WMIs are registered with NHTSA and therefore may not be available in VPIC data sets.

Parameters

NameTypeDefault valueDescription
WMIstringundefinedWorld Manufacturer Identifier
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 single NhtsaResponse object of type DecodeWMIResults in the Results key.

typescript
=> Promise<NhtsaResponse<DecodeWMIResults>>
typescript
interface NhtsaResponse<DecodeWMIResults> = {
  Count: number
  Message: string
  Results: Array<DecodeWMIResults>
  SearchCriteria: string
}
🔍 Click to Show Full Example Response
ts
// Using DecodeWMI('WVW')
const exampleResponse = {
  Count: 1,
  Message: 'Results returned successfully',
  Results: [
    {
      CommonName: 'Volkswagen',
      CreatedOn: '2015-06-01',
      DateAvailableToPublic: '2015-01-01',
      Make: 'VOLKSWAGEN',
      ManufacturerName: 'VOLKSWAGEN AG',
      ParentCompanyName: '',
      URL: 'volkswagenag.com',
      UpdatedOn: '2022-08-08',
      VehicleType: 'Passenger Car',
    },
  ],
  SearchCriteria: 'WMI:WVW',
}

If doFetch is set to false

Returns the 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/DecodeWMI/WVW?format=json'

Type - DecodeWMIResults

Ƭ DecodeWMIResults: Object

Object returned in the Results array of DecodeWMI endpoint response.

In the return object, Results will be an array with a single object of type DecodeWMIResults.

ts
type DecodeWMIResults = {
  CommonName: string
  CreatedOn: string
  DateAvailableToPublic: string
  Make: string
  ManufacturerName: string
  ParentCompanyName: string
  URL: string
  UpdatedOn: string | null
  VehicleType: string
}

Examples

Examples 1-2:

  • Fetches data from VPIC API

  • Returns:

typescript
=> Promise<NhtsaResponse<DecodeWMIResults>>

Example 1: Decode WMI

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

const response = await DecodeWMI('WVW')

Example 2: Decode WMI and doFetch = true

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

const response = await DecodeWMI('1CG', true)

Example 3:

typescript
=> Promise<string>

Example 3: Decode WMI and doFetch = false

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

const url = await DecodeWMI('WAU', false)

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

Released under the MIT License.