
Trim level can change how a vehicle appears in a listing or dealer workflow, but a VIN alone is not useful until it is decoded. This guide shows how to call the VIN decode endpoint, read the trim field, and handle missing values and API errors without treating an unavailable trim as a confirmed vehicle specification.
Request a VIN decode
Send a 17-character VIN to the decode endpoint. Vehicle API supports VIN decoding worldwide, with the fullest data for US-market vehicles. Its vehicle specifications come from NHTSA vPIC.
The request below uses the official control VIN, which decodes to a 2003 Honda Accord. It is an example vehicle, not necessarily the vehicle in your application. Replace the VIN with the one you need to decode and use your own API key in place of YOUR_API_KEY.
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"}'
The JSON request body contains the vin field. The example authenticates with X-API-Key; Authorization Bearer authentication also works. Keep the key on a trusted server rather than embedding it in a public client.
Check that user input has 17 characters before sending it, and show the VIN back to the user when a decode needs confirmation. A length check can catch an incomplete entry, but it does not establish that a VIN is valid or that every specification will be available.
Read the official response
A successful response wraps the decoded vehicle in data. In this example, the field of interest is data.trim, with the value EX-V6.
{
"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."
}
}
First check status; the example is success. The source value is nhtsa, and data holds the decoded fields. Use vin to associate the result with the input, check valid, and read year, make, model, and trim together when displaying the vehicle.
An error response instead has a status of error and an error object containing code and message. Handle that envelope before attempting to read data.trim. Consult the Documentation for the current error codes and their meanings rather than assuming a particular code or limit.
Use trim with the surrounding fields
trim is the decoded trim designation, not a full equipment list or proof of the vehicle’s current condition. In the control response, EX-V6 belongs to the decoded Honda Accord shown by the adjacent identity fields. Preserve the returned value when storing or displaying it; avoid deriving a different trim from the engine or body alone.
The remaining identity and body fields help a user decide whether the result matches the vehicle they entered:
vinidentifies the input associated with this result, whilevalidreports the decoder’s validity result.year,make, andmodelprovide the vehicle description around the trim. The example returns2003,HONDA, andAccord.body,doors, andvehicle_typedescribe the decoded body and vehicle category. The example is a two-door passenger car with a coupe body.
The nested engine object supplies specifications that can be displayed alongside trim. Its cylinders value is a count, displacement_l is displacement in liters, configuration describes the engine layout, model identifies the engine model, hp is horsepower, and fuel is the engine fuel. For the example, displacement is 3 liters and output is 240 horsepower.
fuel_type also describes fuel at the vehicle level. Both it and engine.fuel are Gasoline in this response. Keep the fields distinct in your data model rather than assuming that one is always populated whenever the other is.
transmission.style gives the transmission type, and transmission.speeds gives its number of speeds. The example returns an automatic transmission with five speeds. drive is a separate field and is null here, so the transmission value should not be used to fill it in.
plant.country, plant.city, and plant.state describe the assembly location; the example names Marysville, Ohio, in the United States. manufacturer names the manufacturer in the decoded data. These fields provide context, but neither establishes ownership or the vehicle’s subsequent history.
Interpret nulls and units
Fields that NHTSA does not publish come back as null. Treat a null as unavailable information, not as zero, an empty designation, or a negative assertion about the vehicle. In particular, a null trim should leave the trim unresolved: let a user review or supply it through your own workflow rather than assigning one from nearby fields.
The control vehicle is a gasoline car. Its electrification_level, ev_drive_unit, battery_kwh, charger_level, and charger_power_kw fields are null in the example. Where battery or charger values are returned for a decoded vehicle, the field names specify kilowatt-hours for battery_kwh and kilowatts for charger_power_kw; do not display those nulls as measured values.
Nulls can occur independently. A successful decode with a missing trim is still useful for its other available fields, but an application that requires trim should mark that part of the result as needing review. Keep the original null in storage so that an unavailable value is distinguishable from a user-provided value.
Read the trim in Python
The following example calls the same endpoint with the control VIN. It checks the response envelope before accessing the vehicle data and handles an unavailable trim without substituting a guess. It uses the requests library.
import requests
url = "https://vehicles-api.com/api/v1/vin/decode"
headers = {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {"vin": "1HGCM82633A004352"}
response = requests.post(url, headers=headers, json=payload, timeout=30)
try:
result = response.json()
except ValueError:
response.raise_for_status()
raise ValueError("The API response was not JSON")
if result.get("status") == "error":
error = result.get("error") or {}
raise RuntimeError(
f"Vehicle API error {error.get('code')}: {error.get('message')}"
)
response.raise_for_status()
if result.get("status") != "success":
raise ValueError("Unexpected response status")
vehicle = result.get("data") or {}
trim = vehicle.get("trim")
print("Source:", result.get("source"))
print("VIN:", vehicle.get("vin"))
print("Valid:", vehicle.get("valid"))
print("Year:", vehicle.get("year"))
print("Make:", vehicle.get("make"))
print("Model:", vehicle.get("model"))
print("Trim:", trim if trim is not None else "Unavailable")
The timeout is a client-side choice, not an API limit. In production, read the key from your server’s secret configuration, handle connection failures as well as API errors, and avoid logging the key. If the returned valid value or identity fields do not support your workflow, ask for review rather than presenting the trim as confirmed.
The sample prints “Unavailable” only for presentation; it does not replace a null in the API response. If you persist a user correction, keep it identifiable as a user-supplied value rather than silently changing the decoded result.
Operate the integration
Cache successful VIN decodes to avoid requesting the same relatively stable specifications repeatedly. Key the cache by the VIN, retain the returned source with the data, and choose a refresh policy that suits your application. Allow a refresh when a user disputes a result or when you need to check for updated source data; caching is not a guarantee that every field will remain unchanged.
Plan for both rate limits and a monthly quota. Cache hits can reduce unnecessary requests, while a queue or controlled request rate can help during bulk processing. Inspect error.code and error.message when a request fails, and check the current documentation and your plan for applicable limits; do not assume a fixed allowance from this example.
Keep API errors separate from a successful response containing null fields. An error means the request did not produce the successful data envelope shown above; a null trim in a successful response means the application has a decode but not that particular value. Your interface can offer a retry for an appropriate request failure and a review path for an unresolved trim.
Vehicle API also provides official US safety data for recall campaigns, owner complaints, and NCAP crash ratings. Those safety records cover US-market vehicles only and are matched by make, model, and year; they are not a VIN-specific vehicle history. Live safety data can change as NHTSA publishes updates, so apply a separate freshness policy if you use it alongside cached decoded specifications.
Dutch plate data comes from RDW open data, and Dutch plate results never include a VIN. Do not expect a Dutch plate response to supply the VIN needed for this decode. The decode and safety data are not a vehicle history report and do not provide title, accident, or ownership history.
For an agent integration, Vehicle API is also available through its MCP server. The same distinction matters in an agent’s output: report the returned trim when available, and clearly identify missing values rather than inferring them.
FAQ
Where is the trim level in the response?
Read data.trim after confirming a successful response. The official control VIN returns EX-V6; another VIN can return a different value or null.
Does a successful decode guarantee a trim?
No. A response can contain useful vehicle data while an individual field is null. Treat an unavailable trim as unresolved and provide a review path if your workflow requires it.
Can I use this endpoint for a non-US VIN?
VIN decoding works worldwide for 17-character VINs, but the data is fullest for US-market vehicles. US recall, complaint, and NCAP data has a narrower scope: it covers US-market vehicles and is matched by make, model, and year.
Is the decoded trim a vehicle history report?
No. Trim and the other decoded specifications describe the vehicle as returned by the source; they do not provide title, accident, or ownership history.
Register to start a 7-day free trial and test the decode with your own VINs. Every plan includes the trial; Starter is $19 per month.