Driver License OCR
Extract driver license information from an image, including license number, name, date of birth, and expiry date.
API Version
Extract driver license information from an image or PDF (up to 20 pages). Returns OCR text values, bounding boxes, and confidence scores for each field. Supports optional field censoring on the returned image.
Extracted Fields
| Key | Description |
|---|---|
license_type | License type in Thai (e.g. รถยนต์ส่วนบุคคลชั่วคราว) |
license_number | License number |
name | Holder full name in Thai |
birth_date | Date of birth (Thai locale) |
ID_no | Thai national ID number |
province | Issuing province in Thai |
issue_date | Issue date (Thai locale) |
expired_date | Expiry date (Thai locale) |
license_type_en | License type in English |
license_number_en | License number in English transcription |
name_en | Holder full name in English |
birth_date_en | Date of birth (English locale) |
ID_no_en | Thai national ID number in English transcription |
province_en | Issuing province in English |
issue_date_en | Issue date (English locale) |
expired_date_en | Expiry date (English locale) |
Response Definition
| HTTP Status | Code | Message | Description |
|---|---|---|---|
| 200 | - | - | All pages were processed successfully. |
| 206 | partial_content | Partial content | Some pages were processed successfully, but at least one page failed. Returned only for multi-page input, typically PDF. |
| 400 | bad_request | Bad Request | No page could be processed successfully, or the request content is invalid for this API. |
| 422 | validation_error | Validation Error | Request schema is invalid, such as missing image. |
| 500 | internal_server_error | Internal Server Error | An unexpected server-side error occurred while processing one or more pages. |
Extract Driver License Information
POST
https://api.aigen.online/aiscript/driver-license/v2
Request Body
| Name | Type | Description |
|---|---|---|
| image* | String | Base64-encoded image or PDF (UTF-8). PDFs are processed up to 20 pages. |
| option | Object | Optional configuration object. |
| option.censor_field | List | List of field keys to censor in the returned image. Must match the keys in Extracted Fields. |
Response Schema
Top-level
| Key | Type | Description |
|---|---|---|
status | string | Processing status: success or error. |
request_id | string | Request identifier derived from the upstream gateway client id. |
error | list[ErrorObject] | Page-level or request-level errors. Empty when all pages succeed. |
data | list[PageResult] | Extracted results, one item per processed page. Empty list on 400. |
ErrorObject
| Key | Type | Description |
|---|---|---|
object | string | Always error. |
code | string | Error code (e.g. partial_content, bad_request). |
message | string | Human-readable error description. |
PageResult
Each page is a dictionary keyed by the field names in Extracted Fields. A field is returned as {} when no value is extracted on that page.
| Key | Type | Description |
|---|---|---|
<field_name> | FieldResult | {} | Extracted value for the corresponding driver license field. |
option | OptionResult | {} | Present when option.censor_field is requested. |
FieldResult
| Key | Type | Description |
|---|---|---|
value | string | null | Extracted text value. |
bboxes | list[list[list[int]]] | null | Four-point bounding boxes in original image coordinates. |
bboxes_norm | list[list[list[float]]] | null | Four-point bounding boxes normalized to [0.0, 1.0]. |
confidence | float | null | Confidence score of the OCR result. |
OptionResult
| Key | Type | Description |
|---|---|---|
censored_image | object | null | Returned when censoring is requested and succeeds. |
censored_image.image_base64 | string | Base64-encoded censored image. |
API Response Examples
- 200: OK Success
- 206: Partial Content
- 400: Bad Request
- 422: Validation Error
- 500: Internal Server Error
View Response
{
"status": "success",
"request_id": "4799c6e2-1433-422a-b3cb-69156fef1ac7",
"error": [],
"data": [
{
"license_type": {
"value": "รถยนต์ส่วนบุคคลชั่วคราว",
"bboxes": [
[
[91, 165],
[373, 165],
[373, 201],
[91, 201]
]
],
"bboxes_norm": [
[
[0.065, 0.114],
[0.267, 0.114],
[0.267, 0.139],
[0.065, 0.139]
]
],
"confidence": 0.98
},
"license_number": {
"value": "12345678",
"bboxes": [
[
[733, 167],
[949, 167],
[949, 209],
[733, 209]
]
],
"bboxes_norm": [
[
[0.525, 0.115],
[0.68, 0.115],
[0.68, 0.144],
[0.525, 0.144]
]
],
"confidence": 0.99
},
"name": {
"value": "นาย ตัวอย่าง ใจดี",
"bboxes": [
[
[370, 322],
[945, 322],
[945, 364],
[370, 364]
]
],
"bboxes_norm": [
[
[0.265, 0.222],
[0.677, 0.222],
[0.677, 0.251],
[0.265, 0.251]
]
],
"confidence": 0.97
},
"birth_date": {},
"ID_no": {},
"province": {},
"issue_date": {},
"expired_date": {},
"license_type_en": {},
"license_number_en": {},
"name_en": {},
"birth_date_en": {},
"ID_no_en": {},
"province_en": {},
"issue_date_en": {},
"expired_date_en": {},
"option": {}
}
]
}
View Response
{
"status": "error",
"request_id": "4799c6e2-1433-422a-b3cb-69156fef1ac7",
"error": [
{
"object": "error",
"code": "partial_content",
"message": "Partial content"
},
{
"object": "error",
"code": "no_driver_license_detected",
"message": "Page 2 : can not find driver license card on picture"
}
],
"data": [
{
"license_type": {
"value": "รถจักรยานยนต์ส่วนบุคคล",
"bboxes": [
[
[95, 170],
[345, 170],
[345, 206],
[95, 206]
]
],
"bboxes_norm": [
[
[0.068, 0.118],
[0.247, 0.118],
[0.247, 0.143],
[0.068, 0.143]
]
],
"confidence": 0.96
},
"license_number": {},
"name": {},
"birth_date": {},
"ID_no": {},
"province": {},
"issue_date": {},
"expired_date": {},
"license_type_en": {},
"license_number_en": {},
"name_en": {},
"birth_date_en": {},
"ID_no_en": {},
"province_en": {},
"issue_date_en": {},
"expired_date_en": {},
"option": {}
},
{}
]
}
{
"status": "error",
"request_id": "4799c6e2-1433-422a-b3cb-69156fef1ac7",
"error": [
{
"object": "error",
"code": "bad_request",
"message": "Bad Request"
}
],
"data": []
}
{
"status": "error",
"request_id": "",
"error": [
{
"object": "error",
"code": "validation_error",
"message": "Validation Error"
}
],
"data": []
}
{
"status": "error",
"request_id": "",
"error": [
{
"object": "error",
"code": "internal_server_error",
"message": "Internal Server Error"
}
],
"data": []
}
API Request Examples
- Python
- Nodejs
- PHP
- cURL
import requests
api = "https://api.aigen.online/aiscript/driver-license/v2"
headers = {
"x-aigen-key": "<aigen-key>",
"content-type": "application/json",
}
data = {
"image": "<base64_string>",
"option": {
"censor_field": ["name", "license_number"]
}
}
res = requests.post(api, json=data, headers=headers)
print(res.status_code)
print(res.json())
const axios = require("axios");
const api = "https://api.aigen.online/aiscript/driver-license/v2";
const headers = {
"x-aigen-key": "<aigen-key>",
"content-type": "application/json",
};
const data = {
image: "<base64_string>",
option: {
censor_field: ["name", "license_number"],
},
};
axios
.post(api, data, { headers })
.then((res) => {
console.log(res.status);
console.log(res.data);
})
.catch((err) => {
console.error(err.response?.data || err.message);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.aigen.online/aiscript/driver-license/v2',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"image": "<base64_string>",
"option": {
"censor_field": ["name", "license_number"]
}
}',
CURLOPT_HTTPHEADER => array(
'X-AIGEN-KEY: <aigen-key>',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
curl --location 'https://api.aigen.online/aiscript/driver-license/v2' \
--header 'X-AIGEN-KEY: <aigen-key>' \
--header 'Content-Type: application/json' \
--data '{
"image": "<base64_string>",
"option": {
"censor_field": ["name", "license_number"]
}
}'