
Your app needs a trustworthy way to tell what kind of vehicle a VIN represents (for example, Passenger Car vs. Truck) so you can route leads, price insurance, or enforce fleet policies. By the end of this guide you will decode any 17-character VIN on the server using Vehicle API and read the vehicle_type field reliably, with production-ready Python and PHP snippets, error handling, caching advice, and clear notes on coverage and nulls.
What you get from VIN Vehicle Type
The Vehicle API VIN decoder returns a normalized vehicle_type along with year, make, model, trim, powertrain data, and manufacturing plant details. It works worldwide with fullest coverage for US-market vehicles. The vehicle_type value is sourced from NHTSA vPIC data and is designed to help you classify vehicles consistently across dealer tools, marketplaces, fleets, insurance flows, and AI agents.
- Endpoint: POST https://vehicles-api.com/api/v1/vin/decode
- Auth: X-API-Key: YOUR_API_KEY (Authorization: Bearer YOUR_API_KEY also works)
- Envelope: every response includes status, source, and data on success; or status: error with error.code and error.message
- Key field for this article: data.vehicle_type (for example, PASSENGER CAR)
Vehicle API is available as a JSON REST API at vehicles-api.com and as an MCP server for AI agents at MCP.
Official curl and JSON example
Use this exact curl command against the production endpoint to decode the control VIN (a 2003 Honda Accord). Replace YOUR_API_KEY with your 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 response is a standard envelope with status, source, and data. Copy-pasteable official example:
{
"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."
}
}
Reading the vehicle_type field (and other fields you will use)
For VIN classification, your primary target is data.vehicle_type. It’s a normalized string such as PASSENGER CAR, and is suitable for branching logic, analytics, and filtering pipelines.
- data.vin: The sanitized VIN that was decoded. Cache this as the key for downstream joins.
- data.valid: Boolean VIN checksum/structural validity. Reject or flag invalid VINs early.
- data.vehicle_type: Your classifier (e.g., PASSENGER CAR). Use this to gate features or pricing.
- data.year, data.make, data.model, data.trim: Common identifiers for matching to recall, complaint, and NCAP data (US-market only).
- data.engine and data.transmission: Details that can power pricing, fitment, and underwriting. Nulls can appear where NHTSA does not publish.
- data.plant and data.manufacturer: Origin details used by some marketplaces and audits.
Null handling: Fields that NHTSA does not publish return null. The control VIN is gasoline, so electrification_level and related fields are null. Do not assume EV fields are present.
Server-side integration: POST /vin/decode
Always call the decoder from your server. Do not embed your API key in browser code. The examples below include request timeouts and error envelope handling so you can ship with confidence.
Python (requests) example with timeout and error handling
import requests
API_URL = "https://vehicles-api.com/api/v1/vin/decode"
API_KEY = "YOUR_API_KEY" # Never commit this to client code
def decode_vin(vin: str, timeout_seconds: float = 5.0):
headers = {
"X-API-Key": API_KEY,
"Content-Type": "application/json",
}
payload = {"vin": vin}
try:
resp = requests.post(API_URL, headers=headers, json=payload, timeout=timeout_seconds)
except requests.Timeout:
# Decide your retry policy or surface a 504 to clients
raise RuntimeError("Vehicle API request timed out")
# Parse JSON regardless of HTTP status; the API uses an envelope
try:
body = resp.json()
except ValueError:
raise RuntimeError(f"Vehicle API returned non-JSON (status {resp.status_code})")
status = body.get("status")
if status != "success":
# The error envelope includes error.code and error.message
err = body.get("error", {}) or {}
code = err.get("code", "unknown_error")
message = err.get("message", "Request failed")
raise RuntimeError(f"Vehicle API error: {code} - {message}")
# At this point, we have a data payload from NHTSA
data = body.get("data", {}) or {}
vehicle_type = data.get("vehicle_type") # e.g., "PASSENGER CAR"
# Other useful fields you may store:
vin_out = data.get("vin")
valid = data.get("valid")
year = data.get("year")
make = data.get("make")
model = data.get("model")
return {
"vin": vin_out,
"valid": valid,
"vehicle_type": vehicle_type,
"year": year,
"make": make,
"model": model,
"raw": data, # keep full payload for future use
}
if __name__ == "__main__":
result = decode_vin("1HGCM82633A004352")
print(f"{result['vin']} -> {result['vehicle_type']} ({result['year']} {result['make']} {result['model']})")
PHP (cURL) example with timeout and error handling
<?php
$apiUrl = "https://vehicles-api.com/api/v1/vin/decode";
$apiKey = "YOUR_API_KEY"; // Keep this on the server
function decodeVin($vin, $timeoutSeconds = 5) {
global $apiUrl, $apiKey;
$ch = curl_init($apiUrl);
$headers = [
"X-API-Key: " . $apiKey,
"Content-Type: application/json"
];
$payload = json_encode(["vin" => $vin]);
curl_setopt_array($ch, [
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => $timeoutSeconds,
]);
$responseBody = curl_exec($ch);
if ($responseBody === false) {
$err = curl_error($ch);
curl_close($ch);
throw new RuntimeException("Vehicle API request failed: " . $err);
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$json = json_decode($responseBody, true);
if ($json === null) {
throw new RuntimeException("Vehicle API returned non-JSON (status $httpCode)");
}
if (!isset($json["status"]) || $json["status"] !== "success") {
$code = $json["error"]["code"] ?? "unknown_error";
$message = $json["error"]["message"] ?? "Request failed";
throw new RuntimeException("Vehicle API error: $code - $message");
}
$data = $json["data"] ?? [];
return [
"vin" => $data["vin"] ?? null,
"valid" => $data["valid"] ?? null,
"vehicle_type" => $data["vehicle_type"] ?? null,
"year" => $data["year"] ?? null,
"make" => $data["make"] ?? null,
"model" => $data["model"] ?? null,
"raw" => $data
];
}
try {
$decoded = decodeVin("1HGCM82633A004352");
echo $decoded["vin"] . " - " . $decoded["vehicle_type"] . PHP_EOL;
} catch (Throwable $e) {
// Map to your application's error format
http_response_code(502);
echo "Error: " . $e->getMessage();
}
Understanding the response envelope
Every Vehicle API response uses a consistent envelope so you can centralize client logic:
- status: success or error
- source: nhtsa for VIN decoding responses
- data: present on success; contains the decoded fields
- error: present on error; includes error.code and error.message
On success, use data.vehicle_type and fall back gracefully if a field is null. On error, map error.code and error.message into your API contract and decide whether to retry or surface a clear message upstream.
Coverage notes you should build around
- VIN decoding: Works worldwide for any 17-character VIN. Coverage is fullest for US-market vehicles.
- Safety data (recalls, complaints, NCAP): US-market only, and matched by make + model + year. Use decoded year/make/model to query safety data if you need it.
- Dutch plates (RDW): Available via Vehicle API, but RDW plate data does not include a VIN.
- This is not a vehicle history report: It does not include title events, accidents, or ownership history.
If you are building workflows that mix VIN decodes with US safety data or RDW plate data, keep the boundaries above in mind and avoid implying coverage outside those lines.
Practical implementation details
Input validation and retries
- Validate client VINs for length (17) before calling the API. You can also rely on data.valid in the response for checksum-level validation.
- Use short network timeouts (3–5 seconds) with a single retry on network errors. Do not retry on application-level errors returned by error.code.
Server-only API keys
Authenticate with the X-API-Key header. Authorization: Bearer YOUR_API_KEY also works if your HTTP client prefers it. Never ship your API key to the browser or mobile apps; proxy calls through your server.
Rate limits and monthly quota
Vehicle API enforces plan-based rate limits and monthly quotas. Exact limits depend on your subscription. Inspect HTTP headers and the error envelope to detect limit breaches, and back off or queue requests accordingly. For details, see the Documentation.
Caching decoded VINs
- VINs are immutable identifiers; cache decodes indefinitely keyed by data.vin to prevent duplicated traffic.
- Downstream enrichments (e.g., recalls, complaints, NCAP ratings) may change as NHTSA updates datasets. If you use those, cache them with a reasonable TTL and refresh in the background.
- Stamp your cache entries with the source (nhtsa) and a fetched_at timestamp to aid debugging.
Null fields and forward compatibility
- Some vehicles have incomplete data in NHTSA sources. Expect nulls for fields such as drive, electrification_level, charger_power_kw, and even transmission details on certain models.
- Write accessors that tolerate missing fields and default to safe behavior in your UI and rules engines.
- Do not coerce null EV fields into false values; preserve null to distinguish “not published” from “feature absent.”
Security and observability
- Log status, error.code, and latency but avoid logging full VINs in plaintext where your policy requires masking.
- Normalize vehicle_type casing if you rely on it for joins, but prefer using it as returned to avoid drift.
- Wrap the API in your service with structured error mapping to keep upstream clients stable if you change vendors or endpoints later.
Using vehicle_type in real flows
- Lead routing: Route leads tagged PASSENGER CAR to retail teams; route TRUCK or MULTIPURPOSE PASSENGER VEHICLE to commercial teams.
- Underwriting: Deny certain lines for vehicle types outside your appetite, or require manual review.
- Marketplace filters: Surface curated categories from vehicle_type without maintaining your own mapping table.
- Fleet policy: Enforce access or fuel card limits based on vehicle_type and fuel_type.
Because vehicle_type is standardized from NHTSA, it reduces custom taxonomy drift across your product and data warehouse.
MCP server for AI agents
If you are building AI agents or tools that need structured access, Vehicle API is also exposed as an MCP server at https://vehicles-api.com/mcp. This is useful when you want the agent to request a VIN decode, then ground follow-up reasoning on vehicle_type and other decoded fields without scraping or parsing HTML. For app backends, stick with the HTTP API shown above.
Field-by-field notes for developers
- vin: Use this as your canonical key. Preserve uppercase formatting.
- valid: Treat false as a hard validation failure; reject early to save quota.
- vehicle_type: Primary classifier. It’s a string such as PASSENGER CAR. Persist as-is.
- year/make/model/trim: These are your join keys for US-market recalls, complaints, and NCAP crash ratings within Vehicle API.
- engine: Nested object with cylinders, displacement_l, configuration, model, hp, fuel. Not all subfields are guaranteed for all VINs.
- fuel_type vs. engine.fuel: Either can be present; prefer fuel_type for top-level workflows and engine.fuel for display.
- drive: Can be null. Do not assume FWD/RWD/AWD is always known.
- transmission: Nested object with style and speeds; may be missing for some edge cases.
- plant and manufacturer: Useful for compliance displays or analytics.
Error handling patterns
- status = error: Inspect error.code and error.message. Do not rely exclusively on HTTP status for logic.
- Invalid VIN: Expect a success envelope with valid=false when the string structure fails checksum but is still decodable contextually. In your UX, surface a clear prompt to recheck the VIN.
- Quota or rate limit exceeded: You may receive an error envelope. Respect backoff hints and contact support if you need higher throughput.
Centralize your decoder client with consistent retries on network timeouts and zero retries on application errors returned in the envelope.
End-to-end checklist before going live
- Use POST https://vehicles-api.com/api/v1/vin/decode with X-API-Key in server code only.
- Set a request timeout. Log both timeout and overall latency separately.
- Parse the envelope; branch on status success/error and handle error.code.
- Cache decodes by VIN indefinitely; optionally revalidate on schedule for fields you care about.
- Handle nulls for EV and drivetrain fields without breaking UI or business rules.
- Build coverage-aware flows: safety data is US-market only and matched by make, model, year; RDW plates do not yield VINs.
Where to go next
Read the full API reference and endpoint details in the Documentation. If you are integrating agent tooling, explore the MCP server. To try the API with your own VINs on a server, start the 7-day free trial: Register. You can also explore the homepage at vehicles-api.com.
FAQ
Does the decoder work for non-US VINs?
Yes. The decoder accepts any 17-character VIN worldwide, with the fullest data for US-market vehicles. Some fields may be null where NHTSA does not publish details.
Is the vehicle_type value suitable for access control or pricing?
Yes. vehicle_type is standardized and stable (e.g., PASSENGER CAR). Implement null-safe logic and log unknown cases for review.
How should I handle null EV fields?
Do not coerce nulls to false. Treat null as “not published.” For the control VIN used here (a gasoline vehicle), electrification fields are null by design.
Can I call this from the browser?
No. Keep your API key server-side. Create a backend endpoint that proxies VIN requests to Vehicle API with your key, and apply your own rate limiting and caching.
What safety data can I attach after decoding?
Recalls, owner complaints, and NCAP crash ratings are US-market only and matched by decoded year, make, and model. They are not vehicle history records.