
A VIN can identify a vehicle, but a listing or fleet application may also need a consistent vehicle category. By the end of this walkthrough, you can send a VIN to the decode endpoint, read vehicle_type, and handle missing values and errors without confusing a vehicle type with a body style.
Request the vehicle type for a VIN
Vehicle API decodes 17-character VINs worldwide using NHTSA vPIC data. The available detail is fullest for US-market vehicles, so applications should not assume every VIN will return the same set of populated fields.
Send the VIN in a JSON body to POST https://vehicles-api.com/api/v1/vin/decode. Authenticate with the X-API-Key header; Authorization Bearer also works. This complete request uses the documentation’s control VIN:
curl -X POST "https://vehicles-api.com/api/v1/vin/decode" -H "X-API-Key: YOUR_API_KEY" -H "Content-Type: application/json" -d '{"vin":"1HGCM82633A004352"}'
Replace YOUR_API_KEY with your key before running the request. The VIN in this example identifies a 2003 Honda Accord; it is a control example, not the vehicle a reader is trying to decode. Use the actual vehicle’s 17-character VIN in your application.
The field of interest is data.vehicle_type. The surrounding identification, body, powertrain and assembly information can help a user confirm that the result belongs to the intended vehicle, but those fields do not replace the vehicle type.
Read the official response
A successful response has an envelope containing status, source and data. The following is the official documentation example for the request above:
{
"status": "success",
"source": "nhtsa",
"data": {
"vin": "1HGCM82633A004352",
"valid": true,
"year": 2003,
"make": "HONDA",
"model": "Accord",
"trim": "EX-V6",
"body": "Coupe",
"doors": 2,
"vehicle_type": "PASSENGER CAR",
"engine": {
"cylinders": 6,
"displacement_l": 3,
"configuration": "V-Shaped",
"model": "J30A4",
"hp": 240,
"fuel": "Gasoline"
},
"fuel_type": "Gasoline",
"electrification_level": null,
"ev_drive_unit": null,
"battery_kwh": null,
"charger_level": null,
"charger_power_kw": null,
"drive": null,
"transmission": {
"style": "Automatic",
"speeds": 5
},
"plant": {
"country": "UNITED STATES (USA)",
"city": "MARYSVILLE",
"state": "OHIO"
},
"manufacturer": "AMERICAN HONDA MOTOR CO., INC."
}
}
For this VIN, status is success, source is nhtsa, and data.vehicle_type is PASSENGER CAR. Check the envelope before reading the nested field: an error response has a different shape.
The returned vin lets you associate the result with the request. valid is a Boolean in the example; year, make, model and trim provide identification context. Presenting those details alongside the type helps a user spot an input mistake before applying the category to a listing or fleet record.
Vehicle type and body are different fields
vehicle_type is the broad classification returned by the decoder. In this response it is PASSENGER CAR, while body is Coupe and doors is 2. Keep those values separate in storage and display: body style and door count add detail, but neither is the vehicle type.
For a marketplace, the returned type can be shown as a classification alongside the year, make and model. For a fleet or insurance workflow, retain the source value before applying any internal category mapping; that makes it possible to distinguish the API’s classification from your application’s interpretation.
Powertrain and assembly context
The nested engine object reports six cylinders, a displacement_l of three litres, a V-Shaped configuration, engine model, hp in horsepower and fuel. The separate top-level fuel_type is also Gasoline in this example. These details describe the decoded vehicle; they are not inputs needed to read vehicle_type.
transmission.style is Automatic, and transmission.speeds is the number of transmission speeds, not a measurement of road speed. The plant object supplies assembly country, city and state; manufacturer names the manufacturer returned for the vehicle.
Keep the nested objects in their respective contexts. For example, engine.model is the engine model, whereas the top-level model is the vehicle model. Flattening both into an ambiguously named field can make a vehicle-type record harder to audit.
Handle nulls without changing the classification
The control VIN is a gasoline car. Its electrification_level, ev_drive_unit, battery_kwh, charger_level and charger_power_kw values are null; drive is also null. Fields NHTSA does not publish are returned as null, so your integration must allow for missing data.
A null is not the same as zero, an empty string or a positive assertion that a feature is absent. Preserve it as an unknown or unavailable value in your data model. In a user interface, avoid presenting a missing value as a measured specification.
If populated for a vehicle, battery_kwh is expressed in kilowatt-hours and charger_power_kw in kilowatts. The example provides no numeric values for either field. Similarly, do not infer the missing drive value from the vehicle type, engine or transmission.
Apply the same discipline to vehicle_type: consume the returned value when available, and give your workflow an explicit path for a missing value. A successful decode can still contain null fields, so success alone should not be treated as proof that every attribute is populated.
Use the field in Python
This standard-library example calls the same endpoint and reads the classification with its identifying context. It handles both an HTTP error response and an API error envelope, and it does not turn a missing vehicle type into a fabricated category.
import json
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
url = "https://vehicles-api.com/api/v1/vin/decode"
payload = json.dumps({"vin": "1HGCM82633A004352"}).encode("utf-8")
request = Request(
url,
data=payload,
headers={
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
method="POST",
)
try:
with urlopen(request) as response:
result = json.load(response)
except HTTPError as exc:
try:
result = json.load(exc)
except (ValueError, UnicodeDecodeError):
raise SystemExit(f"HTTP error: {exc.code}")
except URLError as exc:
raise SystemExit(f"Request failed: {exc.reason}")
if result.get("status") != "success":
error = result.get("error") or {}
raise SystemExit(
f"API error: {error.get('code')} — {error.get('message')}"
)
data = result.get("data") or {}
if not data.get("valid"):
raise SystemExit("VIN was not reported as valid; review the response.")
vehicle_type = data.get("vehicle_type")
if vehicle_type is None:
print("Vehicle type is unavailable in this response.")
else:
print("Vehicle type:", vehicle_type)
print("VIN:", data.get("vin"))
print("Year:", data.get("year"))
print("Make:", data.get("make"))
print("Model:", data.get("model"))
print("Source:", result.get("source"))
Set the key before running the sample and replace the control VIN with the VIN supplied by your user. In an application, keep the API key on a trusted server rather than embedding it in code distributed to users.
The sample checks status before accessing data, then checks valid before using the classification. It also tests vehicle_type for None, Python’s representation of JSON null. Your application can route an unavailable type to manual review instead of silently assigning a category.
Plan for errors, limits and reuse
An error response uses status with an error object containing error.code and error.message. Log or surface those values in a form appropriate for your application, and avoid treating an error envelope as an empty successful decode. The HTTP status is also useful when diagnosing a failed request.
Check the Documentation for the current error codes and account-specific limits rather than hard-coding assumptions about them. Your integration should account for both request rate limits and the plan’s monthly quota. Starter is $19 per month, and every plan has a seven-day free trial; the supplied example does not specify numerical rate or quota limits.
Cache a successful decoded VIN when the same vehicle is requested repeatedly, using the VIN to associate the stored response with the vehicle. Retain the source and the returned values, including nulls, so downstream consumers can distinguish the API result from their own mappings. Choose a refresh policy appropriate to your application and consult the documentation for current guidance.
Do not cache an error as though it were a successful vehicle classification. When a decode cannot supply a type, make that state visible to the calling workflow; it is different from receiving a type and mapping it to an internal category.
Developers building agents can also use Vehicle API through its MCP server. The same distinction matters in an agent workflow: return the sourced vehicle type when available, and communicate uncertainty when the field is null or the request fails.
FAQ
Does VIN decoding work outside the United States?
VIN decoding works with 17-character VINs worldwide, with the fullest detail for US-market vehicles. A successful decode may still have null fields where NHTSA does not publish the information.
Is vehicle_type the same as body?
No. In the official example, vehicle_type is PASSENGER CAR and body is Coupe. Store and display them as separate attributes.
Can the vehicle type tell me a car’s history?
No. A VIN decode is not a vehicle history report and does not provide title, accident or ownership history. Vehicle API’s recalls, owner complaints and NCAP ratings cover US-market vehicles only and are matched by make, model and year; they are not a substitute for vehicle-specific history.
Can a Dutch plate supply the VIN for this request?
No. Dutch plate data comes from RDW open data and never includes a VIN. Obtain the VIN separately before using the decode request shown here.
What should I do if vehicle_type is null?
Preserve the missing value and handle it explicitly, for example by asking for manual review. Do not infer a type from body style, fuel or other fields unless that inference is clearly identified as your application’s own interpretation.
Register to start a seven-day free trial and test vehicle_type with your own VINs.
