GetAllMakes
async function GetAllMakes(
doFetch?: boolean
) => Promise<NhtsaResponse<GetAllMakesResults> | string>
💡 More In Depth
See: Package Reference
Description
GetAllMakes
provides a list of all the Makes available in the vPIC Dataset. Each object in the Results
array represents the Make_ID
and the Make_Name
of an individual vehicle Make.
- FYI there are over 10,000 registered makes in the database!
Parameters
Name | Type | Default value | Description |
---|---|---|---|
doFetch? | boolean | false | Whether to fetch the data or just return the URL (default: true ) |
📝 NOTE
Set doFetch
to false
if you want to fetch the data yourself.
- See BYOF - Bring Your Own Fetch for more info.
Returns
Returns a Promise that resolves to NhtsaResponse objects of type GetAllMakesResults in the Results
key.
=> Promise<NhtsaResponse<GetAllMakesResults>>
interface NhtsaResponse<GetAllMakesResults> = {
Count: number
Message: string
Results: Array<GetAllMakesResults>
SearchCriteria: string
}
🔍 Click to Show Full Example Response
// Using GetAllMakes() - Truncated response with 10k+ results
const exampleResponse = {
Count: 10596,
Message: 'Response returned successfully',
Results: [
{
Make_ID: 11897,
Make_Name: ' MID-TOWN TRAILERS',
},
{
Make_ID: 4877,
Make_Name: '1/OFF KUSTOMS, LLC',
},
{
Make_ID: 11257,
Make_Name: '102 IRONWORKS, INC.',
},
{
Make_ID: 6387,
Make_Name: '17 CREEK ENTERPRISES',
},
// ...10k+ more results
],
SearchCriteria: null,
}
If doFetch
is set to false
Returns the URL string that can be used to fetch the data, does not fetch the data internally.
=> Promise<string>
// ex: => 'https://vpic.nhtsa.dot.gov/api/vehicles/GetAllMakes/?format=json'
💡 See: BYOF - Bring Your Own Fetch
Type - GetAllMakesResults
Ƭ GetAllMakesResults: Object
Object returned in the Results
array of GetAllMakes
endpoint response.
In the return object, Results
will be an array with multiple objects of type GetAllMakesResults
.
type GetAllMakesResults = {
Make_ID: number
Make_Name: string
}
Examples
Examples 1-2:
Fetches data from VPIC API
Returns:
=> Promise<NhtsaResponse<GetAllMakesResults>>
Example 1: Get All Makes
import { GetAllMakes } from '@shaggytools/nhtsa-api-wrapper'
const response = await GetAllMakes()
Example 2: Get All Makes and doFetch = true
import { GetAllMakes } from '@shaggytools/nhtsa-api-wrapper'
const response = await GetAllMakes(true)
Example 3:
Does NOT fetch data from VPIC API
Returns:
=> Promise<string>
Example 3: Get All Makes and doFetch = false
import { GetAllMakes } from '@shaggytools/nhtsa-api-wrapper'
const url = await GetAllMakes(false)
// url = 'https://vpic.nhtsa.dot.gov/api/vehicles/GetAllMakes?format=json'