Passport OCR API
Passport OCR API: read a passport with one curl call
Send a photo of a passport or ID card, get the fields back as JSON in about half a second. EU servers, nothing stored, €0.01 a scan, 500 free every month.
1. Get a key
Sign up on vend-id.com/sdk: the key shows on the page in 60 seconds and comes by e-mail. No card.
2. Send an image
Multipart field image, or the raw JPEG, PNG or WebP as the body. Up to 10 MB. Our ICAO 9303 specimen works as a test image.
curl -sO https://vend-id.com/sdk/specimen.jpg
curl https://vend-id.com/v1/mrz \
-H "Authorization: Bearer $VENDID_KEY" \
-F image=@specimen.jpg
3. Read the JSON
{
"format": "TD3",
"document_type": "P",
"issuing_state": "UTO",
"surname": "ERIKSSON",
"given_names": "ANNA MARIA",
"document_number": "L898902C3",
"nationality": "UTO",
"birth_date": "1974-08-12",
"sex": "F",
"expiry_date": "2012-04-15",
"optional_data": "ZE184226B",
"check_digits": { "document_number": true, "birth_date": true, "expiry_date": true, "composite": true },
"mrz": ["P<UTOERIKSSON<<ANNA<MARIA<<<…", "L898902C36UTO7408122F1204159ZE184226B<<<<<10"],
"ms": 550
}
Every check digit is verified before you get the answer: a misread letter fails the check instead of reaching your database. How MRZ check digits work.
4. Handle the errors
422 no_document,no_mrz,blurry,check_digits: ask for a new photo.401 missing_api_key/invalid_api_key.429 quota_exceeded: the free 500 are used up this month.
Node and Python
// Node 18+
const form = new FormData()
form.append('image', new Blob([fs.readFileSync('passport.jpg')]), 'passport.jpg')
const res = await fetch('https://vend-id.com/v1/mrz', {
method: 'POST', headers: { Authorization: `Bearer ${process.env.VENDID_KEY}` }, body: form,
})
const doc = await res.json()
# Python
import os, requests
r = requests.post('https://vend-id.com/v1/mrz',
headers={'Authorization': f"Bearer {os.environ['VENDID_KEY']}"},
files={'image': open('passport.jpg', 'rb')})
doc = r.json()
In the browser instead
No upload form needed: mrz.js opens the camera, frames the document and captures it automatically.
<script src="https://vend-id.com/sdk/mrz.js"></script>
<script>
VendIdMrz.open({ key: 'YOUR_KEY' }).then(doc => fillForm(doc))
</script>
Want the image never to leave the user's phone? The Passport SDK reads on the device: €99 a month per website, unlimited scans. Examples on GitHub (check-in form, curl, Node, Python, MIT).
More
MRZ API prices of every vendor BlinkID alternative Regula alternative Scanbot alternative Dynamsoft alternative MRZ check digits explained SES.Hospedajes check-in Alloggiati Web check-in
Sources
- ICAO Doc 9303, Machine Readable Travel Documents: www.icao.int/publications/pages/publication.aspx?docnum=9303
- VendID API docs: vend-id.com/sdk/docs
Questions
What is a passport OCR API?
An HTTP endpoint that takes a photo of a passport or ID card and returns the fields as JSON. VendID reads the machine-readable zone (MRZ), the two or three lines of characters at the bottom of the data page, and checks the check digits.
Which documents work?
Passports (TD3), ID cards (TD1) and TD2 documents with a machine-readable zone, from every ICAO country.
How fast is it?
0.55 seconds median per read on our GPU when warm; the first call after a quiet spell takes a few seconds.
What does it cost?
€0.01 per successful scan, 500 free every month, no card. Only reads with valid check digits count.
Where is the image processed?
On our GPU servers in Belgium, in memory. The image is dropped after the answer; nothing is stored.