Passport OCR
Key | Description |
---|---|
type | Passport type (P,PA,etc.) |
country_code | Country code (THA,etc.) |
passport_number | Passport number |
surname_en | Surname of passport holder in english |
title_name_en | itle and name of passport holder in english |
title_name_surname_th | Title, name, and surname of passport holder in Thai |
nationality | Nationality of passport holder |
date_of_birth | passport holder’s birth date |
Identification_number | ID number of passport holder |
sex | Sex of passport holder |
height | Height of passport holder |
place_of_birth | passport holder’s birthplace |
date_of_issue | Passport issued date |
date_of_expiry | Passport expired date |
issuing_authority | Passport authorizer |
holder_signature | Holder signature |
mrz_1 | Mrz line 1 |
mrz_2 | Mrz line 2 |
Response Definition
HTTP Status | Code | Message | Description |
---|---|---|---|
200 | - | OCR success. | |
400 | - | Bad Request | error in request or cannot detect passport |
500 | - | Internal server error | some error occurs in server |
Extract Passport Information
POST
https://apis.aigen.online/aiscript/passport-ocr/v2
Request Body
Name | Type | Description |
---|---|---|
image* | String | Base64 image encoded string |
option | Object | (Optional) get optional fields { return_face : bool } True = return face image from a passport. Otherwise, do not return.
|
{
"request_id": "",
"error": [],
"data": [
{
"type": {},
"country_code": {
"value": "THA",
"bboxes": [
[
[
576,
2146
],
[
1888,
2146
],
[
1888,
2213
],
[
576,
2213
]
]
],
"bboxes_norm": [
[
[
0.2283,
0.6151
],
[
0.7483,
0.6151
],
[
0.7483,
0.6343
],
[
0.2283,
0.6343
]
]
],
"confidence": 0.9965
},
"passport_number": {
"value": "ACXXXXXXX",
"bboxes": [
[
[
576,
2219
],
[
1888,
2219
],
[
1888,
2291
],
[
576,
2291
]
]
],
"bboxes_norm": [
[
[
0.2283,
0.636
],
[
0.7483,
0.636
],
[
0.7483,
0.6566
],
[
0.2283,
0.6566
]
]
],
"confidence": 0.9958
},
"surname_en": {
"value": "XXXXXX",
"bboxes": [
[
[
576,
2146
],
[
1888,
2146
],
[
1888,
2213
],
[
576,
2213
]
]
],
"bboxes_norm": [
[
[
0.2283,
0.6151
],
[
0.7483,
0.6151
],
[
0.7483,
0.6343
],
[
0.2283,
0.6343
]
]
],
"confidence": 0.9965
},
"title_name_en": {
"value": "XXXXXXX",
"bboxes": [
[
[
380,
460
],
[
484,
460
],
[
484,
473
],
[
380,
473
]
]
],
"bboxes_norm": [
[
[
0.1506,
0.1318
],
[
0.1918,
0.1318
],
[
0.1918,
0.1356
],
[
0.1506,
0.1356
]
]
],
"confidence": 0.9974
},
"title_name_surname_th": {
"value": "นาย ตัวอย่าง ตัวอย่าง",
"bboxes": [
[
[
379,
480
],
[
489,
480
],
[
489,
492
],
[
379,
492
]
]
],
"bboxes_norm": [
[
[
0.1502,
0.1376
],
[
0.1938,
0.1376
],
[
0.1938,
0.141
],
[
0.1502,
0.141
]
]
],
"confidence": 0.998
},
"nationality": {
"value": "THAI",
"bboxes": [
[
[
380,
501
],
[
411,
501
],
[
411,
511
],
[
380,
511
]
]
],
"bboxes_norm": [
[
[
0.1506,
0.1436
],
[
0.1629,
0.1436
],
[
0.1629,
0.1465
],
[
0.1506,
0.1465
]
]
],
"confidence": 0.9923
},
"date_of_birth": {
"value": "04/03/1979",
"bboxes": [
[
[
576,
2219
],
[
1888,
2219
],
[
1888,
2291
],
[
576,
2291
]
]
],
"bboxes_norm": [
[
[
0.2283,
0.636
],
[
0.7483,
0.636
],
[
0.7483,
0.6566
],
[
0.2283,
0.6566
]
]
],
"confidence": 0.9969
},
"identification_number": {
"value": "1234567890123",
"bboxes": [
[
[
576,
2219
],
[
1888,
2219
],
[
1888,
2291
],
[
576,
2291
]
]
],
"bboxes_norm": [
[
[
0.2283,
0.636
],
[
0.7483,
0.636
],
[
0.7483,
0.6566
],
[
0.2283,
0.6566
]
]
],
"confidence": 0.9971
},
"sex": {
"value": "M",
"bboxes": [
[
[
576,
2219
],
[
1888,
2219
],
[
1888,
2291
],
[
576,
2291
]
]
],
"bboxes_norm": [
[
[
0.2283,
0.636
],
[
0.7483,
0.636
],
[
0.7483,
0.6566
],
[
0.2283,
0.6566
]
]
],
"confidence": 0.6543
},
"height": {
"value": "1.54",
"bboxes": [
[
[
380,
539
],
[
413,
539
],
[
413,
547
],
[
380,
547
]
]
],
"bboxes_norm": [
[
[
0.1506,
0.1545
],
[
0.1637,
0.1545
],
[
0.1637,
0.1568
],
[
0.1506,
0.1568
]
]
],
"confidence": 0.9784
},
"place_of_birth": {
"value": "NAKHONPHANOM",
"bboxes": [
[
[
468,
521
],
[
580,
521
],
[
580,
531
],
[
468,
531
]
]
],
"bboxes_norm": [
[
[
0.1855,
0.1493
],
[
0.2299,
0.1493
],
[
0.2299,
0.1522
],
[
0.1855,
0.1522
]
]
],
"confidence": 0.9658
},
"date_of_issue": {
"value": "09/06/2022",
"bboxes": [
[
[
380,
558
],
[
459,
558
],
[
459,
567
],
[
380,
567
]
]
],
"bboxes_norm": [
[
[
0.1506,
0.1599
],
[
0.1819,
0.1599
],
[
0.1819,
0.1625
],
[
0.1506,
0.1625
]
]
],
"confidence": 0.9549
},
"date_of_expiry": {
"value": "08/06/2032",
"bboxes": [
[
[
576,
2219
],
[
1888,
2219
],
[
1888,
2291
],
[
576,
2291
]
]
],
"bboxes_norm": [
[
[
0.2283,
0.636
],
[
0.7483,
0.636
],
[
0.7483,
0.6566
],
[
0.2283,
0.6566
]
]
],
"confidence": 0.9905
},
"issuing_authority": {
"value": "MINISTRYOFFOREIGNAFFAIRS",
"bboxes": [
[
[
580,
549
],
[
688,
549
],
[
688,
561
],
[
580,
561
]
],
[
[
582,
541
],
[
660,
541
],
[
660,
550
],
[
582,
550
]
]
],
"bboxes_norm": [
[
[
0.2299,
0.1574
],
[
0.2727,
0.1574
],
[
0.2727,
0.1608
],
[
0.2299,
0.1608
]
],
[
[
0.2307,
0.1551
],
[
0.2616,
0.1551
],
[
0.2616,
0.1576
],
[
0.2307,
0.1576
]
]
],
"confidence": 0.9946
},
"holder_signature": {
"value": "xxxxxxxx",
"bboxes": [
[
[
580,
579
],
[
719,
579
],
[
719,
601
],
[
580,
601
]
]
],
"bboxes_norm": [
[
[
0.2299,
0.166
],
[
0.285,
0.166
],
[
0.285,
0.1723
],
[
0.2299,
0.1723
]
]
],
"confidence": 0.9956
},
"mrz_1": {
"value": "X<XXXXXXXXXXX<<XXXXXXX<<<<<<<<<<<<<<<<<<<<<",
"bboxes": [
[
[
576,
2219
],
[
1888,
2219
],
[
1888,
2291
],
[
576,
2291
]
]
],
"bboxes_norm": [
[
[
0.2283,
0.636
],
[
0.7483,
0.636
],
[
0.7483,
0.6566
],
[
0.2283,
0.6566
]
]
],
"confidence": 0.999
},
"mrz_2": {
"value": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"bboxes": [
[
[
576,
2219
],
[
1888,
2219
],
[
1888,
2291
],
[
576,
2291
]
]
],
"bboxes_norm": [
[
[
0.2283,
0.636
],
[
0.7483,
0.636
],
[
0.7483,
0.6566
],
[
0.2283,
0.6566
]
]
],
"confidence": 0.999
}
}
"option": {
"face": {
"bboxes": [
[
369,
766
],
[
495,
641
],
[
638,
784
],
[
512,
909
]
],
"bboxes_norm": [
[
0.3712,
0.7698
],
[
0.498,
0.6442
],
[
0.6419,
0.7879
],
[
0.5151,
0.9136
]
],
"image_b64": "iVBORw0KGgoAAAANSUhEUgAAALE…}
],
"status": "success"
}
{'request_id': '',
'error': [{'object': 'error',
'code': 'bad_request',
'message': 'Bad Request'}],
'data': [{}],
'status': 'error'}
{'request_id': '',
'error': [{'object': 'error',
'code': 'internal_server_error',
'message': 'Page 1 : Internal Server Error'}],
'data': [{}],
'status': 'error'}
import requests
api = "https://apis.aigen.online/aiscript/passport-ocr/v2"
headers = {"x-aigen-key": "<key>"}
data = {"image": "<base64_string>","option": {} } #optional
res = requests.post(api, json=data, headers=headers)
print(res.json())
const axios = require("axios");
const api = "https://apis.aigen.online/aiscript/passport-ocr/v2";
const headers = {
"x-aigen-key": "<key>",
};
const data = { image: "<base64_string>", "option": {} #optional };
axios
.post(api, data, { headers: headers })
.then((res) => {
console.log(res.data);
})
.catch((err) => {
console.error(err.response.data);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://apis.aigen.online/aiscript/passport-ocr/v2',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"image": "<base64_string>",
"option": {} #optional
}',
CURLOPT_HTTPHEADER => array(
'X-AIGEN-KEY: <aigen-key>',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
curl --location 'https://apis.aigen.online/aiscript/passport-ocr/v2' \
--header 'X-AIGEN-KEY: <aigen-key>' \
--header 'Content-Type: application/json' \
--data '{
"image": "<base64_string>",
"option": {} #optional
}'
Last updated