Documents & mediaVIN Decoder
VIN OCR API: Read a VIN from a Photo, Verify It and Decode It
VIN OCR API guide: read a VIN from a photo with Python, fix misread characters with the check digit, confirm with NHTSA and decode the car in one call.
Asking a user to type a Vehicle Identification Number is asking for errors. Seventeen characters, read off a dusty plate at the base of the windshield or a door-jamb sticker at an angle, with an 8 that looks like a B and a 0 that looks like a D. A marketplace listing, an insurance quote or a parts order built on a wrong VIN describes the wrong car.
Taking a photo is easier for the user, but a generic OCR does not solve the problem: it returns a string, confidently, whether or not it is right. A VIN OCR API has to do more than read: it must prove the VIN with its check digit, fix the classic misreads only when the fix is certain, and say clearly when it cannot. This tutorial shows how, in Python, with the VIN Recognition API and a real 314-pixel photo where the reader got one character wrong.
Why generic OCR gets VINs wrong
A VIN has 17 characters from a restricted alphabet: digits and capital letters except I, O and Q, excluded because they are too easy to confuse with 1 and 0. In North America the 9th character is a check digit computed from the other 16, as defined by 49 CFR Part 565; China uses the same rule. Most European makers do not, which matters later.
OCR models are trained on ordinary text, where none of this exists. On VIN photos they make predictable mistakes:
| Read | Should be | Why |
|---|---|---|
O, I, Q |
0, 1, 0 |
Letters that never appear in a VIN |
8 |
B |
Same shape in many stencil and dot-matrix fonts |
D |
0 |
Rounded zero on stamped plates |
Z |
2 |
Embossed digits |
S |
5 |
Low resolution |
* read as X |
nothing | Stars that frame the VIN on plates and stamped frames |
VINs are printed in several places, each with its own difficulty: the windshield plate (glare, reflections), the door-jamb label (small print next to a barcode and other numbers), the stamped frame or firewall (no contrast, often rotated), the manufacturer plate, and the registration document or title (surrounded by other identifiers).
Read a VIN from a photo with Python
POST /v1/vin-photo/read takes the url of an image; decode: true adds the vehicle's make, model, year and engine from NHTSA at no extra credit. The API reference documents every field. The photo is a public Wikimedia Commons image of a door-jamb label, 314 pixels wide.
import requests
HOST = "vin-recognition-read-vin-from-photo-decode.p.rapidapi.com"
API = f"https://{HOST}/v1/vin-photo"
HEADERS = {"x-rapidapi-key": "YOUR_API_KEY", "x-rapidapi-host": HOST}
PHOTO = "https://upload.wikimedia.org/wikipedia/commons/d/d1/Vin_number_11.jpg"
response = requests.post(
f"{API}/read", headers=HEADERS, json={"url": PHOTO, "decode": True}, timeout=60
)
response.raise_for_status()
result = response.json()
print(result["vin"], result["vins"][0]["status"], result["vins"][0]["confidence"])
The real response (the decoded vehicle shortened):
{
"source": "https://upload.wikimedia.org/wikipedia/commons/d/d1/Vin_number_11.jpg",
"mime_type": "image/jpeg",
"found": true,
"vin": "1D4GP25B03B108775",
"count": 1,
"vins": [
{
"vin": "1D4GP25B03B108775",
"read_as": "1D4GP25B038108775",
"status": "corrected",
"confidence": "high",
"check_digit_valid": true,
"corrections": [
{
"position": 11,
"read": "8",
"corrected": "B",
"reason": "8 and B look alike; B makes the check digit right."
}
],
"alternatives": [],
"reason": "The check digit was wrong as read; one character changed, the only change that makes it right. NHTSA's patterns for this maker match it.",
"location": "door_label",
"wmi": "1D4",
"make": "DODGE",
"region": "North America",
"country": "United States",
"model_year": 2003,
"vehicle": {
"found": true,
"manufacturer": "FCA US LLC",
"make": "DODGE",
"model": "Caravan/Grand Caravan",
"series": "RS",
"body_class": "Van",
"drive_type": "FWD/Front-Wheel Drive",
"engine": { "cylinders": 4, "displacement_l": 2.4, "configuration": "In-Line", "fuel": "Gasoline" },
"plant": { "city": "FENTON", "state": "MISSOURI", "country": "UNITED STATES (USA)" }
}
}
],
"image": "readable"
}
The vision model read 1D4GP25B038108775. The API then found that this string fails its own check digit, that exactly one look-alike swap (8 to B in position 11) makes it pass, and that NHTSA's patterns for Dodge accept the result. The answer is the corrected VIN, with read_as and corrections kept so you can show the user what changed. The same photo was sent three times while writing this article, with and without decoding: the model read the 8 every time, and the API corrected it every time.
How the check digit corrects a misread
The correction is plain arithmetic, so you can verify it yourself. Each VIN character has a value (digits keep theirs, letters follow a fixed table), each position a weight; the weighted sum modulo 11 must equal the 9th character (X for 10). The VIN decoder article explains the table in detail. Here is a simplified version of the search the API runs:
VALUES = {
**{str(d): d for d in range(10)},
**dict(zip("ABCDEFGH", range(1, 9))),
**dict(zip("JKLMN", range(1, 6))),
"P": 7,
"R": 9,
**dict(zip("STUVWXYZ", range(2, 10))),
}
WEIGHTS = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2]
LOOK_ALIKES = [("0", "D"), ("0", "8"), ("1", "L"), ("1", "7"), ("2", "Z")]
LOOK_ALIKES += [("3", "8"), ("4", "A"), ("5", "S"), ("6", "G"), ("8", "B")]
LOOK_ALIKES += [("C", "G"), ("E", "F"), ("K", "X"), ("M", "N"), ("P", "R")]
LOOK_ALIKES += [("U", "V")]
def check_digit(vin: str) -> str:
total = sum(VALUES[c] * w for c, w in zip(vin, WEIGHTS))
return "X" if total % 11 == 10 else str(total % 11)
def single_swaps(vin: str) -> list[str]:
fixes = set()
for i, char in enumerate(vin):
for a, b in LOOK_ALIKES:
if char in (a, b):
other = b if char == a else a
candidate = vin[:i] + other + vin[i + 1 :]
if check_digit(candidate) == candidate[8]:
fixes.add(candidate)
return sorted(fixes)
read_as = "1D4GP25B038108775"
print(check_digit(read_as), read_as[8]) # 4 0: the VIN as read is wrong
print(single_swaps(read_as)) # ['1D4GP25B03B108775']: one fix only
One candidate: the correction is safe. When several swaps pass, a blind pick would be right only some of the time, so the API asks NHTSA's vPIC database which candidates decode cleanly for the maker. If exactly one does, it is corrected; otherwise the VIN is ambiguous with the candidates in alternatives. NHTSA also catches the rarer failure, a misread that passes the check digit by chance (1 chance in 11): a VIN that does not match the maker's patterns drops to low confidence.
The five statuses, and what to do with each
Every VIN in the response gets a status, a confidence and a plain-English reason:
status |
Meaning | Action |
|---|---|---|
valid |
Check digit right as read | Use it |
corrected |
Fixed by one look-alike swap, check digit now right | Use it; show corrections if you like |
unverified |
Well formed, from a region where the check digit is optional (most of Europe) | Use it after a glance at the photo |
ambiguous |
Check digit wrong, several fixes possible | Ask for a better photo, or show alternatives |
invalid |
Not 17 readable characters, or a pre-1981 chassis number | Ask the user to type it |
European VINs deserve a word. An Audi VIN such as WAUZZZ8CZ... has a Z in the 9th position, which would be "wrong" under North American rules and is perfectly normal in Europe. The API never "corrects" those: they come back unverified, exactly as printed, with the region, country and make.
In code, the decision is short:
SAFE = {"valid", "corrected", "unverified"}
def vin_from_photo(url: str) -> str | None:
result = requests.post(
f"{API}/read", headers=HEADERS, json={"url": url}, timeout=60
).json()
best = result["vins"][0] if result["found"] else None
if best and best["status"] in SAFE and best["confidence"] != "low":
return best["vin"]
return None # ask for a new photo, or for the VIN typed by hand
Upload a photo from a phone
In an app, the photo comes from the camera, not a URL. POST /v1/vin-photo/read/upload takes multipart/form-data with the field file and an optional decode:
with open("door-label.jpg", "rb") as f:
response = requests.post(
f"{API}/read/upload",
headers=HEADERS,
files={"file": ("door-label.jpg", f, "image/jpeg")},
data={"decode": "true"},
timeout=60,
)
With curl:
curl -X POST "https://vin-recognition-read-vin-from-photo-decode.p.rapidapi.com/v1/vin-photo/read/upload" \
-H "X-RapidAPI-Key: YOUR_API_KEY" \
-H "X-RapidAPI-Host: vin-recognition-read-vin-from-photo-decode.p.rapidapi.com" \
-F "file=@door-label.jpg" -F "decode=true"
PNG, JPEG, WEBP, HEIC (iPhone photos), GIF, BMP and TIFF are accepted up to 20 MB; the type is read from the file's bytes. Rotated and upside-down shots are fine. A photo can hold several VINs (a screenshot of two listings, a title next to a plate): up to 6 are returned, best first, and 4 of them decoded.
Photos without a VIN
A photo with no VIN is an answer, not an error. A real call with a photo of a banana:
{
"source": "https://upload.wikimedia.org/wikipedia/commons/8/8a/Banana-Single.jpg",
"mime_type": "image/jpeg",
"found": false,
"count": 0,
"vins": [],
"image": "no_vin",
"note": "No VIN visible in this image. Photograph the plate at the base of the windshield, the door-jamb label or the registration document."
}
Show note to the user as is. When a VIN is present but blurred or covered by glare, image is unreadable instead, with advice to retake it. Both use 1 credit, since the photo was read. A URL that is not an image (a web page) is refused with 400 unsupported_file and not billed.
Practical advice for the capture screen: frame the 17 characters so they fill a good part of the picture, avoid flash on windshield plates (tilt the phone instead), and crop before uploading when the VIN is a small part of a wide shot.
What it costs
1 credit per photo, VIN decoding included. Failed calls (4xx, 5xx) use none.
| Plan | Price per month | Credits | Price per photo |
|---|---|---|---|
| BASIC | Free | 2 per day | to test |
| PRO | $4.99 | 1,900 | about $0.0026 |
| ULTRA | $14.99 | 5,800 | about $0.0026 |
| MEGA | $49.99 | 19,000 | about $0.0026 |
Beyond the quota, paid plans continue at $0.03 per credit. For comparison, the most-subscribed VIN recognition API on RapidAPI in our market survey charges $19.99 per 1,000 photos ($0.02) and neither verifies nor decodes the VIN; Plate Recognizer's VIN ID costs $0.025 to $0.05 a photo.
Once you have the VIN, the VIN Decoder API adds recalls, owner complaints and crash-test ratings, and the form OCR walkthrough covers the paperwork that often comes with the car.
What the VIN OCR API does not do
- No bounding boxes. You get the VIN and where it was printed (
location, such asdoor_label), not pixel coordinates. - No barcode decoding. It reads the characters printed with the barcode on labels (the same VIN), not the bars.
- No pre-1981 chassis numbers. Older vehicles have shorter, non-standard numbers; they are returned as
invalidwith the reason. - No full European specs. Decoding uses NHTSA, which has full data for vehicles sold in North America; for other VINs you get make, country and a year hint.
- No licence plates. Input is a VIN photo; plate recognition is a different problem.
- No miracles on tiny text. A VIN a few pixels high in a wide shot is lost when the image is resized; crop first.
Frequently asked questions
How do I scan a VIN from a photo in my app?
Send the camera image to /v1/vin-photo/read/upload (or its URL to /v1/vin-photo/read) and use vin when its status is valid, corrected or unverified. Ask for a new photo on ambiguous, invalid, no_vin or unreadable.
Can OCR misread a VIN?
Yes, often: 8 and B, 0 and D, 2 and Z look alike on plates. That is why every North American and Chinese VIN is checked by its check digit, corrected only when a single look-alike swap fixes it, and matched against NHTSA's patterns for the maker.
Does it work with European VINs?
Yes. They are read as printed and returned as unverified, since most European makers do not use the check digit. Region, country and make come from the first three characters.
Does decoding cost extra?
No. decode: true adds make, model, year, body, engine and plant from NHTSA at no extra credit. For recalls and crash ratings, use the VIN Decoder API.
Are the photos stored?
No. Photos are read and discarded; neither the image nor the VIN is stored by the API.
Get started
VIN Recognition API
Read the VIN from a photo of a plate, door label or document, check-digit verified and decoded.
- VIN Decoder
- OCR
- Automotive
- Python
- Computer Vision



