VIN Model Year API Example

By Vehicle API
VIN Model Year API Example

You need a reliable model year from a VIN so your app can price, insure, list, or service the right vehicle. By the end of this walkthrough you will call a single endpoint, parse the year from the response envelope, handle nulls and errors, and cache results to minimize latency and quota usage.

What you get from the VIN decode and where it comes from

The VIN decode endpoint returns a structured response with the model year and core build attributes for any 17-character VIN worldwide. Coverage is fullest for US-market vehicles. The data source is NHTSA vPIC; fields NHTSA does not publish are returned as null. Recalls, complaints, and NCAP ratings in Vehicle API are US-market only and matched by make + model + year, but this article focuses on extracting the year from the VIN decode.

Illustration: VIN Model Year API Example

Note on other registries: Dutch number plates (RDW open data) never include a VIN. This endpoint is not a vehicle history report and does not include title, accident, or ownership history.

Endpoint and authentication

Base URL: https://vehicles-api.com/api/v1

  • Endpoint: POST /vin/decode
  • Purpose: Decode a VIN into year, make, model, trim, and other build attributes
  • Auth: Send X-API-Key: YOUR_API_KEY (Authorization: Bearer YOUR_API_KEY also works)
  • Body: JSON with a single key vin (17 characters)

All responses are returned in a consistent envelope containing status, source, and data on success. On error, status is error and the body includes error.code and error.message.

Make a request for the model year

The following request uses a control VIN for a 2003 Honda Accord to demonstrate the year field. This VIN is a fixed example from the official documentation and may not match your users’ vehicles.

cURL

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

JavaScript (fetch)

async function decodeVinGetYear(vin) {
const res = await fetch("https://vehicles-api.com/api/v1/vin/decode", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": "YOUR_API_KEY"
},
body: JSON.stringify({ vin })
});

// Envelope: { status, source, data } on success; { status: "error", error: { code, message } } on failure
const payload = await res.json();

if (payload.status !== "success") {
// Handle error; do not assume error.code is present beyond the documented shape
const msg = (payload.error && payload.error.message) || "VIN decode failed";
throw new Error(msg);
}

const { data } = payload;

// Extract the model year
const year = data.year; // integer, e.g. 2003

// Practical: cache by VIN string; VIN decode is stable for a given 17-char VIN
// Example: localStorage, Redis, or your datastore of choice
return {
vin: data.vin,
valid: data.valid === true,
year,
make: data.make,
model: data.model,
trim: data.trim
};
}

// Example invocation with the official control VIN
decodeVinGetYear("1HGCM82633A004352")
.then(info => console.log("Decoded:", info))
.catch(err => console.error("Error:", err.message));

Official response example

Here is the exact JSON returned by the official documentation for the control VIN. The key to focus on for this article is year.

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

Field-by-field: extracting and using the model year

The response uses an envelope to communicate status and provenance, and a data object for the decoded attributes. Here are the fields you will actually use to get and validate the model year:

  • status: "success" on a good decode. Always check this before reading the year.
  • source: "nhtsa" indicates vPIC as the source for VIN decoding.
  • data.vin: The VIN string you submitted, useful as a cache key.
  • data.valid: Boolean VIN validity per vPIC. If false, do not trust the year.
  • data.year: Integer model year (e.g., 2003). This is the canonical field for pricing, parts catalogs, insurance rating, and recall lookups.
  • data.make, data.model, data.trim: Strings you will often pair with year to fetch US-market safety data (recalls, complaints, NCAP ratings are matched by make + model + year).
  • data.engine, data.transmission, data.body, data.doors, data.vehicle_type: Helpful for display and parts fitment when used with year.
  • data.plant and data.manufacturer: Provenance and manufacturing info; not commonly needed for model year logic, but useful in audit logs.

Units and types:

  • year is an integer (Gregorian calendar year). No timezone applies.
  • engine.displacement_l is in liters (numeric). engine.hp is horsepower.
  • Nulls indicate the data is not published by the source for that VIN or trim.

Nulls and EV fields

Electrification fields in the example (electrification_level, ev_drive_unit, battery_kwh, charger_level, charger_power_kw) are null because the example VIN decodes to a gasoline vehicle. Do not attempt to infer EV attributes if fields are null. Your integration should:

  • Treat null as “not available from source” rather than “value zero.”
  • Conditionally render EV-specific UI only if the corresponding electrification fields are non-null.
  • Continue to rely on year, make, and model for safety-data joins even if EV fields are null.

Envelope, errors, and validation flow

Every response follows this pattern:

  • On success: status is "success", source identifies the system, and data contains the decoded result.
  • On error: status is "error", and an error object contains error.code and error.message.

Recommended decode-and-validate sequence:

  1. POST the VIN string (must be 17 characters).
  2. Check payload.status. If not "success", read error.message and surface it to the caller or UI.
  3. Read data.valid. If false, do not trust data.year or other attributes; prompt the user to correct the VIN.
  4. Use data.year as your canonical model year. Store alongside vin, make, model, trim for downstream joins.

Be prepared for null values in optional fields. Your code should branch only on the presence of data you require (e.g., year, make, model) and treat other missing fields as optional.

Caching, rate limits, and quotas

VIN decoding is deterministic: a given 17-character VIN will always decode to the same year, make, and model. You should cache successful decodes keyed by vin to reduce latency and conserve usage. Typical strategies include:

  • Application cache (in-memory) for recent lookups.
  • Shared cache (Redis/Memcached) for horizontally scaled services.
  • Database table keyed by vin with the full decoded data blob and a last_seen timestamp.

Rate limits and monthly quota apply at the account level. The API returns standard HTTP status codes; when you approach or exceed your plan’s limits, handle the error envelope and back off or serve from cache. For current limits and quotas, refer to your dashboard and the Documentation.

Plans start with Starter at $19/month, and every plan includes a 7-day free trial. You can begin integrating and testing without commitment.

Working with US safety datasets by year

If you need to join VIN data to safety datasets:

  • Recalls, owner complaints, and NCAP crash ratings are US-market only and matched by make, model, and year rather than by VIN.
  • Use data.year from the VIN decode as the primary key alongside make and model for those lookups.
  • When make or model mappings vary by market, prefer the values returned by the decode for joining to US datasets.

Practical integration notes

  • Idempotency: Multiple calls with the same VIN return the same year. Cache confidently.
  • Case: VIN is typically uppercase. Preserve or normalize to uppercase to maintain consistent cache keys.
  • Validation: If data.valid is false, handle this as user input error rather than a server fault.
  • Time zones: Model year is a calendar year; there are no time zone or DST considerations.
  • Partial data: Some fields may be null for certain markets or trims. Do not coerce null to 0 or empty strings if numeric types are expected downstream.

MCP server for agents and tools

If you are building AI agents or internal tools that communicate over MCP instead of HTTP, Vehicle API also offers an MCP server at MCP. The same data and coverage principles apply: VIN decoding is worldwide (fullest for US-market), and US safety datasets match by make + model + year.

Testing and moving to production

  • Use the control VIN during development to confirm that you are extracting data.year correctly.
  • Add schema guards in your code to ensure year is an integer and present when status is success and valid is true.
  • Instrument caching hit rates; VIN decode requests are ideal candidates for long-lived caches.
  • Monitor for error envelopes and log error.code and error.message for troubleshooting and support tickets.

FAQ

Does VIN decoding work outside the US?
Yes. Vehicle API decodes any 17-character VIN worldwide. Coverage is fullest for US-market vehicles. When the source does not publish certain fields for a market or trim, those fields will be null.

Is the model year always present?
When status is success and data.valid is true, data.year will be present as an integer. If the VIN is invalid, valid will be false and you should not use the year.

Can I look up recalls by VIN directly?
Use the decoded year, make, and model to match US-market recalls, owner complaints, and NCAP ratings. Those datasets are matched by make + model + year rather than by VIN.

How should I handle rate limits?
Cache successful VIN decodes keyed by vin to minimize repeat calls. If you encounter an error envelope related to rate limits or quota, back off and serve from cache. See the account dashboard and the Documentation for current plan details.

Do Dutch plates include the VIN?
No. Dutch plates (RDW open data) never include a VIN. If you need a model year from a plate in the Netherlands, fetch plate data and join on make + model + year where applicable, not on VIN.

Start decoding VINs and extracting the model year in minutes. Create your key and use the 7-day free trial on the Starter plan at $19/month: Register. For reference material and the MCP server, see the Documentation and MCP pages at vehicles-api.com.