Skip to content
On this page

GetAllMakes


typescript
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

NameTypeDefault valueDescription
doFetch?booleanfalseWhether 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 NhtsaResponse objects of type GetAllMakesResults in the Results key.

typescript
=> Promise<NhtsaResponse<GetAllMakesResults>>
typescript
interface NhtsaResponse<GetAllMakesResults> = {
  Count: number
  Message: string
  Results: Array<GetAllMakesResults>
  SearchCriteria: string
}
🔍 Click to Show Full Example Response
ts
// 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.

typescript
=> Promise<string>

// ex: => 'https://vpic.nhtsa.dot.gov/api/vehicles/GetAllMakes/?format=json'

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.

ts
type GetAllMakesResults = {
  Make_ID: number
  Make_Name: string
}

Examples

Examples 1-2:

  • Fetches data from VPIC API

  • Returns:

typescript
=> Promise<NhtsaResponse<GetAllMakesResults>>

Example 1: Get All Makes

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

const response = await GetAllMakes()

Example 2: Get All Makes and doFetch = true

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

const response = await GetAllMakes(true)

Example 3:

typescript
=> Promise<string>

Example 3: Get All Makes and doFetch = false

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

const url = await GetAllMakes(false)

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

Released under the MIT License.