GetWMIsForManufacturer
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
Name | Type | Default Value | Description |
---|---|---|---|
params | Object | undefined | Object of query search names and values to append to the URL as a query string. |
params.manufacturer? | string | number | undefined | Manufacturer Name or ID, or WMI ID (required if !vehicleType) |
params.vehicleType? | string | number | undefined | Optional Vehicle Type search parameter (required if !manufacturer) |
doFetch | boolean | true | Whether 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.
- See BYOF - Bring Your Own Fetch for more info.
Returns
Returns a Promise that resolves to a NhtsaResponse object containing an array of GetWMIsForManufacturerResults objects in the Results
key.
=> Promise<NhtsaResponse<GetWMIsForManufacturerResults>>
type NhtsaResponse<GetWMIsForManufacturerResults> = {
Count: number
Message: string
Results: Array<GetWMIsForManufacturerResults>
SearchCriteria: string
}
🔍 Click to Show Full Example Response
// 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.
=> Promise<string>
// ex: => 'https://vpic.nhtsa.dot.gov/api/vehicles/GetVehicleVariableValuesList/battery%20type?format=json'
💡 See: BYOF - Bring Your Own Fetch
Type - GetWMIsForManufacturerResults
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:
=> Promise<NhtsaResponse<GetWMIsForManufacturerResults>>
Example 1: Get WMIs for Manufacturer
import { GetWMIsForManufacturer } from '@shaggytools/nhtsa-api-wrapper'
const response = await GetWMIsForManufacturer({ manufacturer: 'Mercedes Benz' })
Example 2: Get WMIs for Vehicle Type
import { GetWMIsForManufacturer } from '@shaggytools/nhtsa-api-wrapper'
const response = await GetWMIsForManufacturer({ vehicleType: 'car' })
Example 3: Get WMIs for Manufacturer and Vehicle Type
import { GetWMIsForManufacturer } from '@shaggytools/nhtsa-api-wrapper'
const response = await GetWMIsForManufacturer({
manufacturer: 'honda',
vehicleType: 'car',
})
Examples 4-6:
Does NOT fetch data from VPIC API
Returns:
=> Promise<string>
Example 4: Get WMIs for Manufacturer and doFetch = false
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
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
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'