VIN Validation API for Developers

By Vehicle API
VIN Validation API for Developers

You need to quickly reject mistyped or malformed VINs before you waste time querying downstream services or showing users incomplete results. By the end of this guide, you will validate a VIN on your server using Vehicle API’s VIN Validation endpoint, handle errors reliably, and wire it into your Python or PHP backend with timeouts and basic retries.

What VIN validation does (and when to use it)

The VIN Validation endpoint checks VIN format and verifies the ISO 3779 check digit (the 9th character) locally, without an upstream call. Use it to:

Illustration: VIN Validation API for Developers
  • Gate user input before a decode, recall or pricing flow.
  • Reject obvious non-VIN strings (wrong length, unsupported characters).
  • Confirm the check digit matches the rest of the VIN characters.

This is not a decode and it is not a vehicle history report. VIN decoding works worldwide but is fullest for US-market vehicles. Recalls, complaints and NCAP crash ratings cover US-market vehicles only and are matched by make, model and year. Dutch plates come from RDW open data and never include a VIN.

Endpoint overview

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

  • Endpoint: POST /vin/validate
  • Authentication: Send your key in the X-API-Key header (Authorization: Bearer also works). Do not ship the key in browser code.
  • Request body: JSON with a single field vin
  • Response envelope: status, source, and data on success; or status=error with error.code and error.message on failure
  • Computation: Format and ISO 3779 check-digit validation, computed locally

Refer to the full Documentation for additional endpoints such as VIN decode, recalls, owner complaints and NCAP ratings.

Authentication and server-side only

Always call Vehicle API from your server. Include your key in the X-API-Key header. Do not embed your key into mobile apps or browser code. If you maintain an API gateway, terminate TLS at your edge and forward the header to https://vehicles-api.com/api/v1.

Copy-paste cURL

The following official example validates the control VIN 1HGCM82633A004352 (a 2003 Honda Accord) and returns the computed check digit and a valid flag.

curl -X POST "https://vehicles-api.com/api/v1/vin/validate" -H "X-API-Key: YOUR_API_KEY" -H "Content-Type: application/json" -d '{"vin":"1HGCM82633A004352"}'

The official JSON response

{
    "status": "success",
    "source": "local",
    "data": {
        "vin": "1HGCM82633A004352",
        "valid": true,
        "check_digit": "3"
    }
}

Field usage:

  • status: "success" or "error". Gate your business logic on this.
  • source: "local" indicates no upstream network call was required.
  • data.vin: Echo of the input VIN.
  • data.valid: Boolean result of format + ISO 3779 check-digit validation.
  • data.check_digit: The computed check digit (9th character). Useful for debugging user input.

Python server integration (requests)

This example posts with a JSON body, sets a short timeout, handles network errors, and inspects the envelope for status and error.code.

import requests
from requests.exceptions import RequestException, Timeout

API_URL = "https://vehicles-api.com/api/v1/vin/validate"
API_KEY = "YOUR_API_KEY"

def validate_vin(vin: str, timeout_s: float = 5.0) -> dict:
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_s)
except (Timeout, RequestException) as e:
# Network/timeout. Surface a consistent error shape for your app.
return {
"status": "error",
"error": {
"code": "network_error",
"message": str(e),
}
}

# Non-2xx should still be parsed if the server returns JSON.
try:
body = resp.json()
except ValueError:
return {
"status": "error",
"error": {
"code": "invalid_json",
"message": f"Non-JSON response with status {resp.status_code}",
}
}

if body.get("status") != "success":
# Expect error.code and error.message when status == "error".
err = body.get("error", {}) or {}
return {
"status": "error",
"error": {
"code": err.get("code", "unknown_error"),
"message": err.get("message", "Unknown error"),
}
}

data = body.get("data", {}) or {}
# data should include vin, valid, check_digit
return {
"status": "success",
"data": {
"vin": data.get("vin"),
"valid": data.get("valid"),
"check_digit": data.get("check_digit"),
},
"source": body.get("source"),
}

if __name__ == "__main__":
result = validate_vin("1HGCM82633A004352")
if result["status"] == "success":
print(f"VIN: {result['data']['vin']}, valid={result['data']['valid']}, check_digit={result['data']['check_digit']}")
else:
print(f"Validation failed: {result['error']['code']} - {result['error']['message']}")

Notes:

  • Use json= for POST bodies so requests sets headers correctly and encodes safely.
  • Set a timeout. This endpoint is local on the provider side, so timeouts are typically due to your network, not upstream compute.
  • On status="error", read error.code and error.message. Avoid relying solely on HTTP status codes.
  • For other Vehicle API GET endpoints in your app, pass query parameters via params= to ensure correct encoding and logging.

PHP server integration (cURL)

The following snippet posts the same body with a connection timeout and top-level envelope handling.

<?php

function validate_vin($vin, $timeoutSeconds = 5) {
$url = "https://vehicles-api.com/api/v1/vin/validate";
$headers = [
"X-API-Key: YOUR_API_KEY",
"Content-Type: application/json",
];
$payload = json_encode([ "vin" => $vin ]);

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

$raw = curl_exec($ch);
$curlErr = curl_error($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($curlErr) {
return [
"status" => "error",
"error" => [
"code" => "network_error",
"message" => $curlErr
]
];
}

$body = json_decode($raw, true);
if (json_last_error() !== JSON_ERROR_NONE) {
return [
"status" => "error",
"error" => [
"code" => "invalid_json",
"message" => "Non-JSON response with status $httpCode"
]
];
}

if (!isset($body["status"]) || $body["status"] !== "success") {
$err = isset($body["error"]) ? $body["error"] : [];
return [
"status" => "error",
"error" => [
"code" => isset($err["code"]) ? $err["code"] : "unknown_error",
"message" => isset($err["message"]) ? $err["message"] : "Unknown error"
]
];
}

$data = isset($body["data"]) ? $body["data"] : [];
return [
"status" => "success",
"source" => isset($body["source"]) ? $body["source"] : null,
"data" => [
"vin" => isset($data["vin"]) ? $data["vin"] : null,
"valid" => isset($data["valid"]) ? $data["valid"] : null,
"check_digit" => isset($data["check_digit"]) ? $data["check_digit"] : null,
]
];
}

// Example usage:
$result = validate_vin("1HGCM82633A004352");
if ($result["status"] === "success") {
$d = $result["data"];
echo "VIN: {$d["vin"]}, valid=" . ($d["valid"] ? "true" : "false") . ", check_digit={$d["check_digit"]}\n";
} else {
$e = $result["error"];
echo "Validation failed: {$e["code"]} - {$e["message"]}\n";
}

Notes:

  • Set both CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT to prevent hung sockets.
  • Return a consistent shape from your abstraction so callers can check status and inspect error.code without parsing raw responses.

Interpreting results and wiring into your workflow

Typical flow:

  • Call /vin/validate when a user submits a VIN.
  • If status="success" and data.valid=true, proceed to VIN decode or US-market safety data.
  • If data.valid=false, prompt the user to re-check the 9th character (data.check_digit helps with support troubleshooting).
  • If status="error", map error.code to your UI. Keep a retry/backoff policy for transient network errors on your side.

If you collect Dutch license plates, remember RDW records never include a VIN. Validate a VIN only when you actually have one from the user or partner; do not attempt to synthesize a VIN from Dutch plates.

Response envelope, null fields and forward compatibility

Every Vehicle API response returns an envelope with top-level status and source, plus either data on success or error on failure. Treat unknown keys as forward-compatible and avoid hard failures if new fields are added. Fields can be null on some endpoints; always guard access with get/isset checks as shown above. For VIN Validation specifically, data includes vin, valid and check_digit.

Error handling, rate limits, and quotas

Handle two classes of failures:

  • Transport errors (timeouts, DNS, TLS): catch exceptions (Python) or curl_error (PHP) and surface a synthetic status=error with code=network_error for observability.
  • Application-level errors: if status="error", use error.code and error.message; do not assume HTTP status codes cover all semantics.

Rate limits and monthly quotas depend on your plan. Avoid guessing; consult the Documentation for the current limits. Implement exponential backoff for 429 responses where appropriate and add server-side caching for VIN decodes to minimize repeated calls. VIN validation itself is computed locally by Vehicle API and is inexpensive, but you should still debounce repeated submissions from the same user.

Caching guidance

For the validation endpoint, caching is usually unnecessary beyond short-lived request deduplication because it is a local computation on the provider side. For VIN decodes and safety data that you may request after validation, cache those results in your data store keyed by VIN (or by make+model+year for US-market safety data) to reduce latency and conserve your quota. When a user edits the VIN, invalidate any cached decode keyed to the previous VIN.

Coverage and data sources in context

  • VIN decoding: worldwide coverage, with the fullest detail for US-market vehicles.
  • US safety data: recall campaigns, owner complaints, and NCAP crash ratings are US-market only and matched by make, model and year.
  • Dutch plates: sourced from RDW open data and never include a VIN; treat them as a separate flow in your app.

The validation endpoint itself does not call external sources; it validates format and check digit locally and returns source="local".

MCP access for agents and tools

If you are building AI agents or tools that prefer MCP-style tooling, Vehicle API is also available as an MCP server. You can connect your runtime to MCP at https://vehicles-api.com/mcp and use the same VIN validation capability alongside decode and US safety data retrieval.

Production checklist

  • Call /vin/validate server-side with X-API-Key and a short timeout.
  • Gate downstream calls on status and data.valid.
  • Show users actionable feedback when data.valid=false; hint that the 9th character is the check digit.
  • On status="error", record error.code and error.message for metrics and alerts.
  • Cache decodes and safety lookups keyed by VIN (or make+model+year for safety data) to reduce latency and quota use.
  • Document rate limits and quotas in your codebase with a link to the docs; do not hard-code assumptions.
  • Keep API keys out of client code and rotate them periodically.

FAQ

Does VIN validation decode the vehicle?
No. VIN Validation checks format and the ISO 3779 check digit locally and returns valid plus the computed check_digit. Use the decode endpoint separately if you need year, make, model, trim and other specs.

Will this work for non-US VINs?
Yes. The validation logic is based on ISO 3779 and is not limited to the US. Subsequent data coverage varies: VIN decoding is worldwide (fullest for US-market vehicles); recalls, complaints and NCAP ratings are US-market only.

Can I validate a VIN from a Dutch plate?
Dutch plates from RDW do not include a VIN. If you only have a Dutch plate, do not expect to retrieve or validate a VIN from that plate alone.

What does source="local" mean?
The API computed the result without calling upstream services. You should expect consistent latency and no dependency on external data for this endpoint.

Where do I find rate limits and my monthly quota?
See the plan details in the Documentation. Avoid hard-coding numbers; they may change with your plan.

Start validating VINs in minutes and wire it into your server flow. Create an account on Register to begin your 7-day free trial. Explore the rest of Vehicle API at vehicles-api.com and keep this guide handy as you integrate validation, decoding and US-market safety data.