Radar

Home › Guides

Free VIN Decoder & NHTSA Safety Recall Check in Python (Check Digit + Live API)

2026-12-02 · also on DEV

Every modern vehicle has a 17-character Vehicle Identification Number (VIN) that encodes the manufacturer, model year, assembly plant, and vehicle attributes. When buying a used car or managing a fleet, two questions matter immediately: what exact vehicle is this, and does it have open NHTSA safety recalls?

If you just need to check a single car right now without writing code, you can run a live lookup in the browser at radarbg.com/tools/vin-recall-check (free, no sign-up, backed by the official NHTSA APIs).

Below is how to decode VINs and pull open NHTSA safety recalls programmatically in Python — both directly against the official NHTSA endpoints and in a single combined JSON call for bulk fleet monitoring.

1. How a 17-Character VIN Is Structured (ISO 3779)

A standard 17-character VIN breaks down into three sections:

Note that VINs never contain the letters I, O, or Q to avoid confusion with 1 and 0.

2. Validate the VIN Check Digit Offline in Python

Before calling any API, validate the length, allowed characters, and North American position-9 check digit locally:

import re

TRANSLIT = {
    "A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6, "G": 7, "H": 8,
    "J": 1, "K": 2, "L": 3, "M": 4, "N": 5, "P": 7, "R": 9,
    "S": 2, "T": 3, "U": 4, "V": 5, "W": 6, "X": 7, "Y": 8, "Z": 9,
}
WEIGHTS = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2]

def is_valid_vin(vin: str) -> bool:
    vin = vin.strip().upper()
    if not re.fullmatch(r"[A-HJ-NPR-Z0-9]{17}", vin):
        return False
    total = 0
    for ch, w in zip(vin, WEIGHTS):
        val = int(ch) if ch.isdigit() else TRANSLIT[ch]
        total += val * w
    rem = total % 11
    expected = "X" if rem == 10 else str(rem)
    return vin[8] == expected

print(is_valid_vin("1HGCM82633A004352"))  # True

3. Decode a VIN + Fetch Open NHTSA Safety Recalls

Using the raw NHTSA APIs requires two separate requests: first vpic.nhtsa.dot.gov/api/vehicles/DecodeVinValues/<vin>?format=json to get Make, Model, and ModelYear, and then api.nhtsa.gov/recalls/recallsByVehicle?make=...&model=...&modelYear=... to fetch recalls (plus separate endpoints for complaints and 5-star crash ratings).

If you want decoded specs + open safety recalls in one JSON call (zero dependencies, 25 free keyless calls/day for testing):

import json
import urllib.request

def decode_vin(vin: str) -> dict:
    req = urllib.request.Request(
        "https://radarbg.com/v1/vehicle-recalls-vin-decoder",
        data=json.dumps({"vins": [vin.strip().upper()]}).encode(),
        headers={"Content-Type": "application/json"},
    )
    with urllib.request.urlopen(req, timeout=20) as resp:
        return json.loads(resp.read().decode())

res = decode_vin("1HGCM82633A004352")
car = res["items"][0]
print(f"{car['modelYear']} {car['make']} {car['model']} {car['trim']}")
print(f"Open NHTSA recalls: {car['recallCount']}")

Real output from running the snippet above:

2003 HONDA Accord EX-V6
Open NHTSA recalls: 24

4. Important Caveat About NHTSA Recall Data

NHTSA recall campaigns are published by make, model, and model year (not per individual VIN repair history). That means the API returns every safety recall issued for that vehicle model/year — to confirm whether a specific recall repair has already been completed on a specific car, check with an authorized dealer or the manufacturer's recall portal.

5. Automating Fleet Recall Monitoring

If you manage a fleet or used-car inventory, you can schedule a weekly check (for example via Python cron or our free ready-to-import n8n template at radarbg.com/no-code/vehicle-recalls-vin-decoder) that diffs recallCount against last week's snapshot and alerts your team only when a new NHTSA campaign appears.

Disclosure: I build the free VIN decoder and API used in this post, and the article was written with AI assistance. If a code sample does not work for you, tell us at radarbg.com/support and we fix it.

More guides

EN