IDCard OCR
Extract ID CARD information from an image or photo. Currently only Thai ID Card is supported. Confidence score is scored from the OCR result.
info
Confidence score is -1.0 when the value of each validation field is False.
IDCard OCR
Extract ID CARD information from an image or photo Currently only Thai ID Card is supported. Confidence score is scored from the OCR result.
Response Definition
http status | error code | error message | description |
---|---|---|---|
200 | - | - | OCR successful |
206 | partial_content | partial_content | Some page of request is invalid |
400 | no_id_card | no idcard on image | Can't detect ID CARD on image Confidence score is -1.0 when the value of each validation field is False. |
Request Options
option key | description | what change |
---|---|---|
censor_field | censor source image depend on given input fields the list of censor fields like ["id_number","title_name_surname_th"] | response data each page has key "option" in "option" has "processed_image" that contain censored_image in base64 format |
return_face | Set true to enable return of facial image in UTF-8 Base64 format | response data each page has key "option" in "option" has "face" that contain face_image in base64 format |
return_gender | Set true to return of the gender information | esponse data each page has key "option" in "option" has "gender" that contain "M"/"F"/"N/A" |
return_signed | Set true to enable detection of overlaying signed on top of the document's photos or images | response data each page has key "option" in "option" has "signed" that contain true/false |
do_field_validation | Set true to enable field validation | response data "id_number" has 2 new key valid(bool), error_message(List[str]) |
return_datetime_iso | Set true to enable add date time iso format to field date time | response data "dob_th","dob_en","doi_th","doi_en","doe_th","doe_en", has 3 new key valid(bool), datetime_iso(str) |
Extract ID card information
POST https://apis.aigen.online/aiscript/idcard/v2
Request Body
Name | Type | Description |
---|---|---|
image | String | Base64 image encoded string |
option | Object | Specify optional features like { censor_field:[field_array] return_face: true, ... } |
Responses
- 200: OK
- 400: Bad Request Invalid input
View Response
{
"status": "success",
"error": [
{
"object": "error",
"code": "string",
"message": "string"
}
],
"data": [
{
"option": {}
},
"string"
],
"request_id": "string"
}
View Response
{
"status": "error",
"request_id": "Unique id of the response",
"error": [
{
"object": "error",
"code": "no_id_card",
"message": "no idcard on image"
}
],
"data": null
}
Example Code
- Python
- Node.js
- PHP
- cURL
import requests
api = "https://apis.aigen.online/aiscript/idcard/v2"
headers = {"x-aigen-key": "<key>"}
data = {
"image": "base64_image",
"option": {} #optional
}
res = requests.post(api, json=data, headers=headers)
print(res.json())
const axios = require("axios");
const api = "https://apis.aigen.online/aiscript/idcard/v2";
const headers = { "x-aigen-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/idcard/v2',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"image": "<base64_string>",
"option" : {}
}',
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/idcard/v2' \
--header 'X-AIGEN-KEY: <aigen-key>' \
--header 'Content-Type: application/json' \
--data '{
"image": "<base64_string>",
"option" : {}
}'