API Documentation (Version 1.1)

API Documentation

Perform OCR and extract MRZ data from a scanned profile page

GET https://api.iapp.co.th/passport-ocr/ocr

Input: A scanned profile page's image of a passport

Output: A JSON formatted result of the MRZ data extracted from on a profile page of the input image.

If you input file is multiple page PDF, it will return a JSON array contain each page results. Please see example below.

Request Body

Name
Type
Description

file*

File

Image/PDF file upload (PNG, JPEG, JPG, PDF)

apikey*

String

iApp's API Key issued from https://ai.iapp.co.th

{
    "check_composite": "0",
    "check_date_of_birth": "2",
    "check_expiration_date": "7",
    "check_number": "0",
    "check_personal_number": "7",
    "country": "UKR",
    "date_of_birth": "910824",
    "expiration_date": "230925",
    "method": "direct",
    "mrz_type": "TD3",
    "names": "MARIANA TKACHENKO",
    "nationality": "UKR",
    "number": "XX000000",
    "personal_number": "1234567890",
    "raw_text": "P<UKRTKACHENKO<<MARIANAK<<<<<<<<<<<<<<<<<<<<<<<<<<\nXXOO0000<OUKR9108242F23092571234567890<<<<70",
    "sex": "F",
    "surname": "TKACHENKO",
    "type": "P",
    "valid_composite": false,
    "valid_date_of_birth": true,
    "valid_expiration_date": true,
    "valid_number": false,
    "valid_personal_number": true,
    "valid_score": 61
}

Output JSON Response

Field name
Description
Example Value

check_composite

Overall check digit for upper and middle machine readable lines

4

check_date_of_birth

Check digit on the date of birth.

4

check_expiration_date

Check digit on the expiration date

4

check_number

Check digit on the document number

6

check_personal_number

Check digit on National ID Card number (personal number)

3

country

Issuance of this document in 3 Letters Country Code

THA

date_of_birth

Holder's date of birth in YYMMDD format.

930710

expiration_date

Date of Document Expiration in YYMMDD format.

250324

face

Photo of holder in base64 format

/9j/4AAQSkZJRgABAQAAAQABAAD/....

method

Reading method: always "direct"

direct

mrz_type

Type of MRZ can be either: "TD1", "TD2", "TD3", "MRVA", "MRVB"

TD3

names

Holder's first name

MATHANIDA

nationality

Holder's nationality in 3 Letters Country Code

THA

number

Document number (Passport number)

AC1062346

personal_number

National ID Card number (personal number)

0012345678913<

raw_text

Raw MRZ text

P<THAPOSHNASWADIWONG<<MATHANIDA<<<<<<<<<<<<<\nAC10623466THA9307104F25030440012345678913<34

sex

Gender of holder. can be either "M" or "F".

F

surname

Holder's sur name

POSHNASWADIWONG

type

MRZ document type field

P<

valid_composite

Overall check digit validity

TRUE

valid_date_of_birth

Date of birth check digit validity

TRUE

valid_expiration_date

Expiration date check digit validity

TRUE

valid_number

Number check digit validity

TRUE

valid_personal_number

Personal number check digit validity

TRUE

valid_score

Total validity score (0-100)

100

Examples

Example 1: Ukraine Passport (Image Input)
{
    "check_composite": "0",
    "check_date_of_birth": "2",
    "check_expiration_date": "7",
    "check_number": "0",
    "check_personal_number": "7",
    "country": "UKR",
    "date_of_birth": "910824",
    "expiration_date": "230925",
    "method": "direct",
    "mrz_type": "TD3",
    "names": "MARIANA TKACHENKO",
    "nationality": "UKR",
    "number": "XX000000",
    "personal_number": "1234567890",
    "raw_text": "P<UKRTKACHENKO<<MARIANAK<<<<<<<<<<<<<<<<<<<<<<<<<<\nXXOO0000<OUKR9108242F23092571234567890<<<<70",
    "sex": "F",
    "surname": "TKACHENKO",
    "type": "P<",
    "valid_composite": false,
    "valid_date_of_birth": true,
    "valid_expiration_date": true,
    "valid_number": false,
    "valid_personal_number": true,
    "valid_score": 61,
    "face": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/..."
}
Example 2: Thailand passport (Image Input)
{
    "check_composite": "4",
    "check_date_of_birth": "4",
    "check_expiration_date": "4",
    "check_number": "6",
    "check_personal_number": "3",
    "country": "THA",
    "date_of_birth": "930710",
    "expiration_date": "250304",
    "method": "direct",
    "mrz_type": "TD3",
    "names": "MATHANIDA",
    "nationality": "THA",
    "number": "AC1062346",
    "personal_number": "0012345678913<",
    "raw_text": "P<THAPOSHNASWADIWONG<<MATHANIDA<<<<<<<<<<<<<\nAC10623466THA9307104F25030440012345678913<34",
    "sex": "F",
    "surname": "POSHNASWADIWONG",
    "type": "P<",
    "valid_composite": true,
    "valid_date_of_birth": true,
    "valid_expiration_date": true,
    "valid_number": true,
    "valid_personal_number": true,
    "valid_score": 100,
    "face": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/..."
}
Example 3: Thailand passport (Multiple Page PDF Input)
[{
    "check_composite": "4",
    "check_date_of_birth": "4",
    "check_expiration_date": "4",
    "check_number": "6",
    "check_personal_number": "3",
    "country": "THA",
    "date_of_birth": "930710",
    "expiration_date": "250304",
    "method": "direct",
    "mrz_type": "TD3",
    "names": "MATHANIDA",
    "nationality": "THA",
    "number": "AC1062346",
    "personal_number": "0012345678913<",
    "raw_text": "P<THAPOSHNASWADIWONG<<MATHANIDA<<<<<<<<<<<<<\nAC10623466THA9307104F25030440012345678913<34",
    "sex": "F",
    "surname": "POSHNASWADIWONG",
    "type": "P<",
    "valid_composite": true,
    "valid_date_of_birth": true,
    "valid_expiration_date": true,
    "valid_number": true,
    "valid_personal_number": true,
    "valid_score": 100,
    "face": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/..."
},{
    "check_composite": "4",
    "check_date_of_birth": "4",
    "check_expiration_date": "4",
    "check_number": "6",
    "check_personal_number": "3",
    "country": "THA",
    "date_of_birth": "930710",
    "expiration_date": "250304",
    "method": "direct",
    "mrz_type": "TD3",
    "names": "MATHANIDA",
    "nationality": "THA",
    "number": "AC1062346",
    "personal_number": "0012345678913<",
    "raw_text": "P<THAPOSHNASWADIWONG<<MATHANIDA<<<<<<<<<<<<<\nAC10623466THA9307104F25030440012345678913<34",
    "sex": "F",
    "surname": "POSHNASWADIWONG",
    "type": "P<",
    "valid_composite": true,
    "valid_date_of_birth": true,
    "valid_expiration_date": true,
    "valid_number": true,
    "valid_personal_number": true,
    "valid_score": 100,
    "face": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/..."
}]

Last updated