/ocr/idcard
1.API Specification
2.Request Params
3.Response Params
4.Error Codes
5.Sample
1.API Specification
This API is used to recognize ID card of Thailand, and extract the key information.
Image spec
1. Format: JPG(JPEG), PNG, e-aadhaar(PDF)
2. Between 128*128 and 6000*6000 (pixels), Recommended resolution: 1280*1280
3. File size: no larger than 5 MB
Request Method
POST
Request URL
https://cloudapi.thailand.accuauth.com/ocr/idcard
Debugging Tool
2.Request Params
2.1 Request Header
Parameter | Type | Required | Description |
---|---|---|---|
X-DF-API-ID | string | Yes | For API credentials,Please visit API Request |
X-DF-API-SECRET | string | Yes | For API credentials,Please visit API Request |
2.2 Request Body
Fields | Type | Description | |
---|---|---|---|
optional | file | file | Binary data of the image |
optional | image_base64 | string | Base64 encoded data of image |
Either parameter
file
orimage_base64
must be provided as a request parameter.You MUST add image stream to multipart/form-data section of POST message when using
file
parameter.
3.Response Params
Fields | Type | Description |
---|---|---|
request_id | string | Unique id of each request |
status | string | Response status, OK if request success, other if failed; See Error Codes for details |
results | array | The array of card ocr results,See results belowed for details |
Elements in results
:
Fields | Type | Description |
---|---|---|
card_side | string | The side of card: front or back |
card_type | string | ID or ALIEN (NON THAI IDENTIFICATION CARD) |
card_info | object | The key infomation of card |
Elements in the card_info
- Card info on the front
Fields | Type | Description |
---|---|---|
id_number | string | ID card number |
type_en | string | Type of the ID Card |
type_th | string | Type of the ID Card (In Thai) |
name_en | string | Name with assigned gender titles such as ""Miss""Mrs" and "Mr" |
name_th | string | Name (in Thai) |
last_name_en | string | Last name |
birthday_en | string | Date of birth |
birthday_th | string | Date of birth (In Thai) |
birthday_s | string | Formatted date of birth: dd-mm-yyyy |
issue_date_en | string | Issue date |
issue_date_th | string | Issue date (In Thai) |
issue_date_s | string | Formatted issue date: dd-mm-yyyy |
expiry_date_en | string | Expiry date |
expiry_date_th | string | Expiry date (In Thai) |
expiry_date_s | string | Formatted expiry date: dd-mm-yyyy |
religion_th | string | Religion (In Thai) |
issuing_officer_th | string | Issuing officer (In Thai) |
address_th | string | The address (In Thai) |
picture_number | string | Picture number |
- Card info on the back
Fields | Type | Description |
---|---|---|
id_number | string | ID card number |
laser_number | string | Laser number |
Response Syntax
- Front of card
{
"request_id": "TID8bf47ab6eda64476973cc5f5b6ebf57e",
"status": "OK",
"results": [{
"card_side": "front",
"card_type": "ID",
"card_info":{
"id_number":"*****",
"type_en":"Thai National ID Card",
"type_th":"บัตรป*****น",
"name_en":"Miss *****",
"name_th":"น.ส. ***** *****",
"last_name_en":"*****",
"birthday_en":"20 Feb. 1995",
"birthday_th":"20 ก.พ. 2538",
"birthday_s":"20-02-1995",
"issue_date_en":"15 Nov. 2016",
"issue_date_th":"15 พ.ย. 2559",
"issue_date_s":"15-11-2016",
"expiry_date_en":"19 Feb. 2025",
"expiry_date_th":"19 ก.พ. 2568",
"expiry_date_s":"19-02-2025",
"religion_th":"พุทธ",
"issuing_officer_th":"***** *****",
"address_th":"****** ******* **** ***** ***",
"picture_number": "xxxx-xx-xxxxxxx"
}
}]
}
- Back of card
{
"request_id": "TID9567cb773ee645f9b20a9593f4d1c35a",
"results": [
{
"card_info": {
"card_number": "BORA-2.0-01-xxxx",
"laser_number": "ME0-1187***-**"
},
"card_type": "ID",
"card_side": "back"
}
],
"status": "OK"
}
4.Error Codes
Common error codes of this API:
Http Status Code | Status field |
Description |
---|---|---|
400 |
INVALID_ARGUMENT | Request parameter is invalid |
400 |
DETECTION_FAILED | Detect image failed |
401 |
UNAUTHORIZED | Unauthorized or access is denied |
401 |
KEY_EXPIRED | Your API ID has expired |
403 |
NO_PERMISSION | You are not authorized to use this API |
403 |
OUT_OF_QUOTA | API calls quota exceeded |
403 |
RATE_LIMIT_EXCEEDED | API request frequency exceeds the limit |
404 |
NOT_FOUND | Requested API cannot be found |
500 |
INTERNAL_ERROR | Internal server error |
Comment: Please see the reason
field for details when the above 40X error occurred
Response Syntax
{
"status": "INVALID_ARGUMENT",
"reason": "must specify 'file' or 'image_base64' argument",
"request_id": "TID8bf47ab6eda64476973cc5f5b6ebf57e"
}