VIN Check Digit API for Developers

By Vehicle API
VIN Check Digit API for Developers

You need a fast, deterministic way to reject bad VINs before you spend cycles decoding them or fetching recalls. By the end of this guide, you’ll validate a VIN’s ISO 3779 check digit on your server using Vehicle API’s VIN Check Digit endpoint, handle errors consistently, and ship production-ready Python and PHP integrations that never expose your API key in the browser.

What this endpoint does (and when to use it)

The VIN Check Digit endpoint confirms whether a 17-character VIN passes ISO 3779 format and check-digit rules. It computes the 9th-character check digit locally—no upstream calls—so you can validate inputs at the edge or gateway before you:

Illustration: VIN Check Digit API for Developers
  • Call VIN decoding to identify year/make/model/trim
  • Join US-market safety datasets like recalls, owner complaints, and NCAP crash ratings
  • Persist vehicle records in dealer, marketplace, fleet or insurance workflows

If the check digit is invalid, you can immediately return a user-facing error without incurring downstream latency or quota usage.

Endpoint, method, and authentication

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

  • Endpoint: POST /vin/validate
  • Auth header: X-API-Key: YOUR_API_KEY (Authorization: Bearer YOUR_API_KEY also works)
  • Content-Type: application/json

Always call this endpoint from your server. Do not place API keys in browser JavaScript. If you are building an agent or tool that needs in-process validation, consider the MCP server: MCP.

Response envelope, errors, and nulls

Every response is wrapped in an envelope:

  • status: "success" or "error"
  • source: "local" for this endpoint (no upstream dependency)
  • data: present on success; contains vin, valid, and check_digit
  • error: present on error; contains error.code and error.message

For VIN validation, all returned fields are deterministic; you should not see null values in a successful response. Handle the "error" envelope path defensively in production (e.g., malformed payloads). When "status" is "success" but data.valid is false, the VIN failed the ISO 3779 check-digit validation and should not proceed to decoding or downstream safety lookups.

Official cURL example

Copy, paste, and run this server-side. Replace YOUR_API_KEY with your key.

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

Official JSON example

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

Field usage:

  • data.vin: Echo of the submitted VIN for auditing and caching.
  • data.valid: Boolean; gate downstream calls on this flag.
  • data.check_digit: String; the computed check digit (the 9th character). Useful for debugging user typos and explaining why a VIN failed validation.

Python (requests) integration

This snippet posts JSON with a short timeout, checks both the envelope and the computed validity, and branches on "error.code" when present. Keep this server-side (web service, worker, or CLI). For GET endpoints elsewhere in the API you would pass params=..., but this endpoint is POST with json=.

import requests

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

def validate_vin(vin: str, timeout_secs: float = 5.0) -> dict:
headers = {
"X-API-Key": API_KEY,
"Content-Type": "application/json",
}
try:
resp = requests.post(API_URL, headers=headers, json={"vin": vin}, timeout=timeout_secs)
except requests.RequestException as e:
# Network/timeout layer; log and raise or map to your app error model
raise RuntimeError(f"VIN validation request failed: {e}") from e

# Always parse JSON; the API returns an envelope
data = resp.json()

# Envelope-level error handling
if data.get("status") == "error":
# You can inspect data.get("error", {}).get("code") for programmatic handling
code = (data.get("error") or {}).get("code")
message = (data.get("error") or {}).get("message")
raise ValueError(f"VIN validation error ({code}): {message}")

# Success path
payload = data.get("data") or {}
if not isinstance(payload, dict):
raise ValueError("Unexpected response shape: missing data object")

# Use the fields you need
return {
"vin": payload.get("vin"),
"valid": payload.get("valid"),
"check_digit": payload.get("check_digit"),
"source": data.get("source"),
}

if __name__ == "__main__":
result = validate_vin("1HGCM82633A004352")
if result["valid"]:
print(f"VIN {result['vin']} passed check-digit validation (digit={result['check_digit']}).")
# Proceed to decoding/joins, e.g., call your VIN decode step next.
else:
print(f"VIN {result['vin']} failed check-digit validation. Do not proceed.")

PHP (cURL) integration

This example uses cURL with a short timeout and handles the "error" envelope before reading the data object. Keep this PHP code on the server (not embedded in client-side scripts).

<?php
$apiUrl = "https://vehicles-api.com/api/v1/vin/validate";
$apiKey = "YOUR_API_KEY";
$payload = json_encode(["vin" => "1HGCM82633A004352"]);

$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-API-Key: " . $apiKey,
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);

$response = curl_exec($ch);
if ($response === false) {
$err = curl_error($ch);
curl_close($ch);
throw new RuntimeException("VIN validation request failed: " . $err);
}
curl_close($ch);

$data = json_decode($response, true);

if (!is_array($data)) {
throw new RuntimeException("Unexpected response: not valid JSON");
}

if (isset($data["status"]) && $data["status"] === "error") {
$code = isset($data["error"]["code"]) ? $data["error"]["code"] : "unknown_error";
$message = isset($data["error"]["message"]) ? $data["error"]["message"] : "Unknown error";
throw new RuntimeException("VIN validation error ($code): $message");
}

if (!isset($data["data"]) || !is_array($data["data"])) {
throw new RuntimeException("Unexpected response: missing data object");
}

$vin = $data["data"]["vin"] ?? null;
$valid = $data["data"]["valid"] ?? null;
$digit = $data["data"]["check_digit"] ?? null;

if ($valid === true) {
echo "VIN $vin passed check-digit validation (digit=$digit)\n";
// Continue to your decode pipeline...
} else {
echo "VIN $vin failed check-digit validation\n";
}
?

Production notes: caching, quotas, and timeouts

  • Deterministic and local: This endpoint’s "source" is "local", so validation is instant and offline-resilient on the provider side. You should still use short client timeouts (3–5 seconds) for network resilience.
  • Cache validated VINs: Cache successful validations keyed by the raw 17-character string. Because the algorithm is deterministic, you can cache indefinitely or for the lifetime of your record, and avoid revalidating the same VIN many times.
  • Rate limits and monthly quota: Plans include quotas and rate limits. If you approach limits, prioritize a check-digit gate before any heavier calls. See plan-specific details in your dashboard and the Documentation.
  • Error handling: On error envelopes, check error.code and error.message to map to your app’s error taxonomy. Log both the "vin" you attempted and the returned "check_digit" when educating users about typos.
  • Input hygiene: Strip whitespace, uppercase the VIN, and reject any string not exactly 17 characters before sending to the API. The check digit is the 9th character.

How this fits with decoding and safety data

Once a VIN passes validation, you can decode it to year, make, model, trim, engine, transmission, and assembly plant (sourced from NHTSA vPIC). VIN decoding works worldwide, with fullest coverage for US-market vehicles. Safety datasets—recall campaigns, owner complaints, and NCAP crash ratings—are US-market only and are matched by make + model + year.

For Dutch registrations, Vehicle API uses RDW open data. Dutch plate lookups never include a VIN; treat registration workflows separately from VIN-based pipelines.

This service is not a vehicle history report. It does not include title, accident, or ownership history. If you need a quick overview of features and pricing, visit the homepage at vehicles-api.com. Starter is $19/mo and every plan includes a 7-day free trial. You can start validating VINs in minutes.

Security and deployment guidelines

  • Server-only keys: Keep X-API-Key in server environments (backend app, API gateway, or serverless functions). Never embed keys in browser code or mobile apps without a secure proxy.
  • Auth flexibility: X-API-Key is the standard header; Authorization: Bearer YOUR_API_KEY is also supported if that simplifies middleware.
  • Timeouts and retries: Use conservative timeouts (3–5s). For this endpoint, retries are rarely necessary because the provider computation is local; prefer a single attempt and surface an actionable message to the user on network failure.
  • Observability: Log the response "status", "source", and "data.valid". Include a correlation ID from your own request context for traceability.
  • Idempotency: VIN validation is a pure function of the input VIN. De-duplicate work via caching and avoid fan-out calls when users paste the same VIN repeatedly.

Interpreting failures and user messaging

If data.valid is false, the VIN fails the ISO 3779 check-digit test. Common causes:

  • O/0 and I/1 or Q confusion when transcribing
  • Missing or extra characters (must be exactly 17)
  • Non-alphanumeric characters or lowercase input

Provide a clear message to end users. When helpful, show them the computed check_digit and indicate the 9th character is the check digit so they can correct a single-character typo quickly.

Scaling patterns for marketplaces, fleets, and insurers

  • Pre-ingestion gate: Validate at upload time in your admin UI and again at ingestion time in your ETL. Reject early to protect decode quotas and safety data joins.
  • Batch pipelines: For bulk imports, validate first, write pass/fail classification, and only enqueue valid VINs for decode and enrichment.
  • Edge functions: If you use an API gateway, run a lightweight server function that calls /vin/validate before routing to heavier microservices.
  • Agents and tools: If you’re building an AI agent that must confirm VIN shape and check digit quickly, run the same call via the MCP server at MCP.

Testing with a known control VIN

The control VIN used in the docs and examples is 1HGCM82633A004352 (a 2003 Honda Accord). It’s suitable for smoke tests and integration checks. Remember that this is a test fixture—it is not your user’s car. Live recall counts and safety data evolve as NHTSA and RDW publish updates; you should treat those datasets as dynamic, while the check-digit computation remains static.

End-to-end workflow sketch

  1. Receive user input (VIN string). Normalize: trim, uppercase, ensure length 17.
  2. Call POST /vin/validate with json={"vin": "..."} and your X-API-Key header.
  3. If status == "error": map error.code to a user-visible message and stop.
  4. If status == "success" and data.valid == false: show corrective guidance; do not proceed.
  5. If data.valid == true: cache the result and continue to your VIN decode step and any US-market safety joins (recalls, complaints, NCAP ratings) as needed.

Troubleshooting checklist

  • Got a 4xx with an error envelope? Inspect error.code and error.message. Common root causes are missing X-API-Key, wrong Content-Type, or malformed JSON.
  • Seeing intermittent network issues? Add a short timeout and one retry at most. Because source is "local," server-side latency is minimal beyond network transit.
  • Unexpected "valid" false? Verify you are passing the VIN exactly as 17 uppercase characters and not stripping the 9th character or altering whitespace incorrectly.
  • Caught by rate limits? Validate once per VIN and cache. Check your dashboard for limits and plan upgrades.

FAQ

Is this a vehicle history report?
No. Vehicle API validates VIN format and check digits, decodes VINs, and joins US-market safety data (recalls, owner complaints, NCAP crash ratings). It does not provide title, accident, or ownership history.

Does VIN validation work outside the US?
Yes. The check-digit algorithm and format validation are ISO 3779-based and apply worldwide. VIN decoding coverage is worldwide with fullest coverage for US-market vehicles. US safety datasets are US-market only and matched by make + model + year.

Can I validate Dutch plates to get a VIN?
Dutch plate data is sourced from RDW open data and never includes a VIN. Treat plate workflows independently from VIN validation and decoding.

What happens on errors or rate limits?
All errors return an envelope with status: "error" plus error.code and error.message. For rate limits and monthly quotas, refer to your dashboard and the API docs. Add lightweight caching to minimize repeat validations for the same VIN.

Can I use this from the browser?
Do not embed API keys in browser or mobile apps. Call the endpoint from your server or via a secure backend-for-frontend. If you need agent tooling, consider the MCP server.

Start validating VINs in minutes. The Starter plan is $19/month and every plan includes a 7-day free trial. Create your account now: Register. For full endpoint details and coverage notes, see the Documentation or visit vehicles-api.com.