VIN Body Style API for Developers

By Vehicle API
VIN Body Style API for Developers

You need a reliable way to extract a vehicle’s body style and door count from a VIN so your app can display the right badges, filter inventory, and quote insurance accurately. By the end of this guide, you’ll be able to integrate the Vehicle API’s VIN decoding endpoint server-side to return a vehicle’s body and doors fields from a 17-character VIN—complete with production-ready Python and PHP samples, error handling, caching tips, and coverage notes.

What this integration delivers

The Vehicle API exposes a single JSON REST endpoint to decode a VIN and return normalized vehicle specs. For body style use cases, you’ll use POST https://vehicles-api.com/api/v1/vin/decode and read the body and doors fields from the response envelope. Decoding works worldwide and is fullest for US-market vehicles; electrification fields will be null for non-EV VINs. Safety datasets (recalls, complaints, NCAP ratings) are US-market and matched by make + model + year, but are not part of this body style call.

Illustration: VIN Body Style API for Developers

Highlights for developers:

  • Endpoint: POST /api/v1/vin/decode with JSON body {"vin": "…"}.
  • Auth: X-API-Key: YOUR_API_KEY header (Authorization: Bearer YOUR_API_KEY also works).
  • Response envelope: status, source, data on success; or status: error with error.code and error.message.
  • Core fields for this article: data.body (string), data.doors (integer).
  • Nulls: Fields not published by NHTSA return null; handle gracefully.
  • Server-only: Never ship your key to the browser; call from your backend.

Explore the broader platform at https://vehicles-api.com and the MCP server at MCP if you’re building AI agents.

Endpoint and request shape

Use the VIN decode endpoint to return a normalized set of vehicle attributes, including body style and number of doors:

  • Method: POST
  • URL: https://vehicles-api.com/api/v1/vin/decode
  • Headers: X-API-Key: YOUR_API_KEY, Content-Type: application/json
  • Body JSON: {"vin": "1HGCM82633A004352"} (example VIN for documentation)

The same endpoint covers any 17-character VIN worldwide. Data is primarily sourced from NHTSA vPIC for US-market vehicles; fields not provided by NHTSA return null. This is not a vehicle history product (no title, accident, or ownership history).

Official cURL request

Copy this cURL call to verify your credentials and inspect the response envelope. Replace YOUR_API_KEY with your actual key; keep the JSON body as-is to reproduce the docs example.

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"}'

Server-side integration: Python and PHP

The following samples implement production basics: server-side calls with timeouts, envelope parsing, explicit handling for nulls, and error propagation using error.code and error.message. Use json= for POST bodies (params= is used for GET endpoints; this endpoint is POST). Set conservative network timeouts and avoid unbounded retries.

Python (requests)

import requests

API_URL = "https://vehicles-api.com/api/v1/vin/decode"
API_KEY = "YOUR_API_KEY" # Never store in client-side code

def decode_vin_body_style(vin: str, timeout_seconds: float = 5.0):
headers = {
"X-API-Key": API_KEY,
"Content-Type": "application/json",
}
try:
resp = requests.post(API_URL, headers=headers, json={"vin": vin}, timeout=timeout_seconds)
except requests.RequestException as e:
# Network/transport error: surface a retriable error to your app
return {"ok": False, "error": {"code": "network_error", "message": str(e)}}

# Parse JSON envelope
try:
payload = resp.json()
except ValueError:
return {"ok": False, "error": {"code": "invalid_json", "message": "Non-JSON response from Vehicle API"}}

# Envelope pattern: status + (data | error)
status = payload.get("status")
if status != "success":
# Expecting error.code and error.message on failure
err = payload.get("error", {}) or {}
return {"ok": False, "error": {"code": err.get("code", "unknown_error"),
"message": err.get("message", "Unknown error from Vehicle API")}}

data = payload.get("data", {}) or {}

# Extract body and doors, which may be null if not published for the VIN
body_style = data.get("body")
doors = data.get("doors")

# Optional additional fields that may help with UX or analytics
vin_returned = data.get("vin")
make = data.get("make")
model = data.get("model")
year = data.get("year")

return {
"ok": True,
"source": payload.get("source"),
"vin": vin_returned,
"year": year,
"make": make,
"model": model,
"body": body_style,
"doors": doors
}

if __name__ == "__main__":
result = decode_vin_body_style("1HGCM82633A004352")
if result["ok"]:
print(f"{result['year']} {result['make']} {result['model']} — body: {result['body']}, doors: {result['doors']}")
else:
print(f"Vehicle API error [{result['error']['code']}]: {result['error']['message']}")

PHP (cURL)

<?php
function decodeVinBodyStyle(string $vin, float $timeoutSeconds = 5.0): array {
$url = "https://vehicles-api.com/api/v1/vin/decode";
$headers = [
"X-API-Key: YOUR_API_KEY", // Keep server-side only
"Content-Type: application/json"
];
$payload = json_encode(["vin" => $vin], JSON_UNESCAPED_SLASHES);

$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => $timeoutSeconds,
]);

$raw = curl_exec($ch);
if ($raw === false) {
$err = curl_error($ch);
curl_close($ch);
return ["ok" => false, "error" => ["code" => "network_error", "message" => $err]];
}
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($raw, true);
if (!is_array($payload)) {
return ["ok" => false, "error" => ["code" => "invalid_json", "message" => "Non-JSON response from Vehicle API"]];
}

if (($payload["status"] ?? null) !== "success") {
$err = $payload["error"] ?? [];
return ["ok" => false, "error" => ["code" => $err["code"] ?? "unknown_error", "message" => $err["message"] ?? "Unknown error from Vehicle API", "http_status" => $httpStatus]];
}

$data = $payload["data"] ?? [];
return [
"ok" => true,
"source" => $payload["source"] ?? null,
"vin" => $data["vin"] ?? null,
"year" => $data["year"] ?? null,
"make" => $data["make"] ?? null,
"model" => $data["model"] ?? null,
"body" => $data["body"] ?? null, // May be null if not published
"doors" => $data["doors"] ?? null, // Integer or null
];
}

// Example usage:
$result = decodeVinBodyStyle("1HGCM82633A004352");
if ($result["ok"]) {
echo sprintf("%s %s %s — body: %s, doors: %s\n",
$result["year"], $result["make"], $result["model"],
$result["body"] ?? "unknown",
$result["doors"] !== null ? $result["doors"] : "unknown"
);
} else {
echo "Vehicle API error [".$result["error"]["code"]."]: ".$result["error"]["message"]."\n";
}

Official JSON response and the fields to use

The docs example below decodes the control VIN 1HGCM82633A004352. These are the official values; use them to validate your parser and response envelope handling.

{
    "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."
    }
}

Fields you’ll use for body style workflows:

  • data.body: Body style string, e.g., "Coupe".
  • data.doors: Number of doors as an integer, e.g., 2.
  • data.year, data.make, data.model, data.trim: Useful for UI and filters alongside body style.
  • status and source: status must be "success" before reading data; source indicates the upstream dataset ("nhtsa").

Notes on nulls and coverage:

  • Nulls are expected when a field is not available from NHTSA for a given VIN. Do not coerce null to zero or empty strings; let your frontend default to “unknown” or hide unavailable specs.
  • VIN decoding works worldwide but is most complete for US-market vehicles.
  • Safety datasets (recalls, complaints, NCAP crash ratings) are US-market only and matched on year + make + model. They are separate from the decode call and not needed for body style.
  • Dutch plates come from RDW open data and never include a VIN; use VIN when body style is required.

Response envelope, errors, rate limits, and quotas

Every response uses an envelope:

  • Success: {"status": "success", "source": "nhtsa", "data": {...}}.
  • Error: {"status": "error", "error": {"code": "…", "message": "…"}}.

Your integration should branch on status. On error, surface error.code and error.message to logs and, where appropriate, to end users. Common scenarios to handle:

  • Invalid VIN length or characters: your app should validate 17 characters before calling.
  • Network timeouts or transient 5xx responses: return a retriable application error; don’t infinite-retry.
  • Rate limiting or quota exhaustion: treat as a fast-fail, back off, and cache aggressively.

Rate limits and monthly quota depend on your plan. Avoid hardcoding assumptions about limits; inspect response codes and read the Documentation for current details. Starter is $19/mo, and every plan includes a 7-day free trial. If you hit rate limits, prefer local caching for decoded VINs and batch your backfills during off-peak windows.

Caching decoded VINs and serving body style at scale

VIN-to-spec is immutable for production VINs. Cache positive responses keyed by the 17-character VIN for a long TTL (days to months). This reduces latency and protects your quota and rate limits. You can also persist the envelope’s source and a processing timestamp to aid debugging and cache audits.

Recommendations:

  • On success, cache body, doors, year, make, model, trim, transmission.style/speeds, and engine summary for downstream features.
  • On error, cache short-lived negative results by VIN and error.code to dampen repeated invalid VIN calls.
  • Normalize case: the API returns canonical casing for make/model; store as-is and only format for display.
  • Do not overwrite a previous successful decode with an error result; maintain last-good data.

If you are building AI agents or workflows that need tool access instead of raw HTTP, consider the MCP server at MCP. For REST integrations, explore the platform at https://vehicles-api.com.

Security, timeouts, and reliability

Keep secrets server-side only. Do not embed X-API-Key or Authorization Bearer tokens in browser code or mobile apps. Restrict access to your backend endpoint that accepts VINs from clients. Log request IDs and error.code values for support and observability.

Set explicit network timeouts (for example, 5 seconds as shown), and consider circuit breakers in high-throughput systems. Retries should be bounded and only for idempotent errors. The decode endpoint is POST, but the request is safe to retry on network failure since it is a pure lookup.

Putting body style and doors to work

Common ways to use body and doors:

  • Inventory: Render badges and filters for “Coupe”, “Sedan”, “SUV”, etc., and filter by two-door vs. four-door.
  • Quoting: Insurance and warranty products often price on body style and door count; store and reuse decoded values.
  • Search relevance: Boost similarity when a shopper wants “2-door coupes”.

Because body and doors are part of the normalized decode, you can ship one server route that takes a VIN and returns only the fields your UI needs. Cache and reuse for consistent UX across pages.

Testing checklist

  • Happy path: The docs VIN 1HGCM82633A004352 returns body "Coupe" and doors 2; your code extracts both values.
  • Nulls: Simulate a VIN where body or doors might be null; ensure the UI handles unknown values gracefully.
  • Errors: Force an invalid VIN and verify your code reads error.code and error.message from the envelope.
  • Timeouts: Drop your outbound connectivity and confirm your timeout/reporting path is exercised.
  • Caching: Confirm cache hits for repeated VINs and that errors do not overwrite last-good data.

Frequently asked questions

Does the VIN decoding work outside the United States?
Yes. VIN decoding works worldwide, with the most complete coverage for US-market vehicles. Fields not available from NHTSA may return null.

Are recalls, complaints, and NCAP ratings returned by this body style endpoint?
No. Those are US-market safety datasets matched by make + model + year and are not part of the /vin/decode response used for body style. Use VIN decode for specs; use safety endpoints when you specifically need safety data.

Can I look up body style by license plate?
Dutch plates are supported via RDW open data and never include a VIN; body style requires VIN-based decoding for consistent results. US plate lookup is not live.

How should I handle null fields like electrification_level or drive?
Treat null as “unknown” and avoid coercing to defaults. Display optional specs only when present.

What happens when I exceed my plan’s rate limit or monthly quota?
The API responds with an error envelope. Back off, surface error.code and error.message, and serve cached results. See the Documentation for current limits.

Ready to ship a VIN Body Style integration? Start your 7-day free trial and get an API key now: Register. If you’re building tool-using agents, explore the MCP server next.