Fields and MRZ
What each field contains and how the MRZ is checked.
Subscribe on RapidAPIPages
| Field | Required | Page |
|---|---|---|
front_page | Yes | The photo/data page: the holder's photo, personal details and the MRZ |
last_page | No | The last page, on passports that print the holder's address and family details there |
One file per field. Each page is read on its own and the results are combined. meta.pages lists the pages
received, front_page first.
Fields
| Field | Page | Format | Notes |
|---|---|---|---|
full_name | front | string | As printed |
given_name | front | string | Given name(s) |
surname | front | string | Surname / family name |
date_of_birth | front | YYYY-MM-DD | |
nationality | front | 1–3 letters | Code used on travel documents, for example IND or D (Germany) |
passport_number | front | string | Without spaces |
issue_date | front | YYYY-MM-DD | |
expiry_date | front | YYYY-MM-DD | |
issuing_country | front | 1–3 letters | Issuing country or authority code |
sex | front | M, F or X | X when the document shows an unspecified marker |
place_of_birth | front | string | As printed |
place_of_issue | front | string | As printed |
father_name | last | string | Father or legal guardian |
mother_name | last | string | |
spouse_name | last | string | |
address | last | string | As printed, lines joined with , |
file_number | last | string | Without spaces |
previous_passport | last | object | { number, issue_date, place_of_issue }, or null when none is listed |
mrz | front | object | See below; null when no MRZ line was read |
Every field is always present. It is null when the value is missing, unreadable or ambiguous, and last-page fields
are null when no last_page was uploaded. The API never guesses:
- Dates are converted to
YYYY-MM-DDonly when the printed date is unambiguous. - Look-alike characters (
O/0,I/1) in passport and file numbers are never swapped. - Country fields contain codes only. When the code cannot be read but the MRZ verifies, the code printed in the MRZ is used.
MRZ
The machine readable zone is the two lines of <-padded text at the bottom of the photo page.
| Field | Meaning |
|---|---|
mrz.line1 | First line, as read (spaces removed), with one kind of correction: see below |
mrz.line2 | Second line, as read (spaces removed), with two kinds of correction: see below |
mrz.check_digits_valid | true when all five check digits match, false when any does not, null when line 2 was not read as a complete 44-character line |
check_digits_valid is calculated by the API using the passport MRZ rules of ICAO Doc 9303. It is not an estimate.
A false value usually means a character was misread: treat the MRZ, and the fields it covers (passport number,
dates of birth and expiry), with care.
Corrections. The API corrects common reading errors only where the result can be confirmed:
- Digits in line 2. Some positions can only hold digits (dates and check digits). A letter read there (for example
Zinstead of2, orOinstead of0) is replaced with the digit it resembles, but only if every check digit is then valid. - Passport number in line 2. When the passport number in line 2 fails its check digit, the passport number printed on the page is tried in its place, and kept only if every check digit is then valid.
- Start of line 1. Line 1 always starts with
Pand a type character. When these are missing and the issuing-state code that follows matches the nationality in line 2 or the issuing country on the page, they are restored. - Fillers. Missing or extra
<fillers are fixed where their count is unambiguous.
Otherwise lines are returned as read. All check digits are in line 2, so check_digits_valid is based on line 2
alone. Line 1 (document type, issuing country and name) has no check digits, so a true result does not confirm it.
Tips for good results
- Upload each page flat and in focus; on the front page, keep the whole MRZ visible.
- Avoid glare and strong shadows; crop out the background if you can.
- PDFs must contain selectable text. Scanned PDFs without text cannot be read: upload the scan as an image instead.