Universal javascript wrapper for the NHTSA.dot.gov VPIC 'vehicles' API, useful for VIN decoding, etc.
npm install @shaggytools/nhtsa-api-wrapper---
A universal (browser/server) javascript wrapper for the National Highway Traffic
Safety Administration (NHTSA) Vehicle Information API (VPIC).
The VPIC API is primarily used for decoding useful information from a Vehicle Identification Number
(VIN) in the United States and Canada. It can also be used to get all models of a make, to decode
WMIs, get all makes for a certain year, and more.
---
---
- Introduction
- Install
- Node Quick Start
- Browser Quick Start
- API Reference
``sh [npm]`
$ npm install @shaggytools/nhtsa-api-wrapper
`sh [yarn]`
$ yarn add @shaggytools/nhtsa-api-wrapper
`sh [pnpm]`
$ pnpm add @shaggytools/nhtsa-api-wrapper
Decoding a VIN is as easy as importing the DecodeVinValues function and calling it
with a VIN.
Make sure to first install via your favorite package manager or use a CDN.
`javascript
import { DecodeVinValues } from '@shaggytools/nhtsa-api-wrapper'
const results = await DecodeVinValues('WA1A4AFY2J2008189')
/*
results = {
Count: 136, - number of Results objects returned
Message: 'Results returned successfully ...',
SearchCriteria: 'VIN:WA1A4AFY2J2008189',
Results: [ {...} ] - an array with single object of type DecodeVinValuesResults
}
*/
/ You can also use destructuring to get the Results object /
const { Results } = await DecodeVinValues('WA1A4AFY2J2008189')
/* This endpoint only returns a single object in the Results array
The first object in the array is the decoded VIN data */
const decodedVehicle = Results[0] // equals an object of type DecodeVinValuesResults
`
For a full example response see: DecodeVinValues
All available endpoints can be found here: VPIC API Endpoints
You can use the package directly in html script tags using a CDN. There are several options for CDN
providers.
For targeting modern browsers, you can use the ESM versions with