🪪✏️ Photographed Thai National ID Card With Signature Detection
🪪✏️ บริการ AI แกะข้อความจากรูปสำเนาบัตรประชาชน
Welcome to Photographed Thai National ID Card With Signature Detection API, an AI product developed by iApp Technology Co., Ltd. Our API is designed to extract text information from photographed copies of Thai National ID cards (both color and black & white) and detect signatures. The system can automatically locate ID cards in images and return accurate text information such as ID number, name, surname, date of birth, and expiry date in JSON format.
Visit our API Portal to test the Photographed Thai National ID Card With Signature Detectiont OCR API with your own images.
Getting Started
-
Prerequisites
- An API key from iApp Technology
- Photographed copy of Thai national ID card
- Supported file formats: JPEG, JPG, PNG, HEIC, HEIF
- Maximum file size: 2MB
-
Quick Start
- Processing time: 1-3 seconds per image
- Automatic card detection and cropping
- Support for both color and black & white copies
-
Key Features
- Detailed field extraction including:
- ID number
- Full name (Thai and English)
- Date of birth
- Address
- Expiry date
- Signature detection
- Flexible JSON response format
- Detailed field extraction including:
-
Security & Compliance
- GDPR and PDPA compliant
- No data retention after processing
Please visit API Portal to view your existing API key or request a new one.
Example
This API is optimized for OCR from printed copies of ID cards. For OCR directly from physical ID cards, please use Thai National ID Card OCR instead.
Request
curl -X POST https://api.iapp.co.th/thai-national-id-card-with-signature/front
-H "apikey: YOUR_API_KEY"
-F "file=@/path/to/idcard.jpg"
Response
{
"address_district": "บางละมุง",
"address_full": "XXXXXX XXXXXX ต.หนองปรือ อ.บางละมุง จ.ชลบ ุรี",
"address_number": "XXXXXX XXXXXX",
"address_postal_code": "20150",
"address_province": "ชลบุรี",
"address_subdistrict": "ต.หนองปรือ",
"date_of_birth": "XX มี.ค. 2500",
"date_of_expire": "XX มี.ค. 2568",
"file_name_id_card": "front.jpg",
"fullname_en": "Mrs. XXXXXX Lopez",
"fullname_th": "นาง XXXXXX โลเ ปช",
"init_en": "Mrs.",
"init_th": "นาง",
"name_en": "XXXXXX",
"name_th": "XXXXXX",
"national_id": "34117XXXXXX334",
"process_time": 2.1,
"reason_code_api": 200,
"reason_code_id_card": 1,
"reason_code_id_card_national_id": 1,
"reason_code_id_card_signature": 0,
"reason_codename_id_card_signature": 1,
"request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx",
"surname_en": "Lopez",
"surname_th": "โลเปช"
}
Features & Capabilities
Core Features
- Automatic ID card detection in images
- Support for both color and black & white copies
- Signature detection
- Fast processing time (1-3 seconds)
- Support for multiple file formats
Image Requirements
- Minimum card size: 600px width, 400px height
- Maximum file size: 2MB
- Supported formats: JPEG, JPG, PNG, HEIC, HEIF
Response Fields
Field | Type | Description |
---|---|---|
address_district | String | District Name |
address_full | String | Full Address |
address_number | String | Home Address |
address_postal_code | String | Postal Code |
address_province | String | Province Name |
address_subdistrict | String | Sub District Name |
date_of_birth | String | Date of Birth in Thai |
date_of_expire | String | Date of Expiry in Thai |
file_name_id_card | String | Filename of image |
fullname_en | String | Name and Surname in English |
fullname_th | String | Name and Surname in Thai |
init_en | String | Name Title in English |
init_th | String | Name Title in Thai |
name_en | String | Name in English |
name_th | String | Name in Thai |
national_id | String | National ID Number |
process_time | Float | Processing Time (sec.) |
reason_code_api | Integer | Response Status Code |
reason_code_id_card | Integer | 0 - ID Card Not Found in Image, 1 - ID Card Found in Image |
reason_code_id_card_national_id | Integer | 0 - National ID Number Not Found, 1 - National ID Number Found |
reason_codename_id_card | Integer | Code explaining the reason_code_id_card_national_id . (TODO) |
reason_code_id_card_signature | Integer | 0 - Signature Not Found on paper, 1 - Signature Found on paper |
reason_codename_id_card_signature | Integer | Code explaining reason_code_id_card_signature . (TODO) |
request_id | String | Request ID from API Gateway |
surname_en | String | Surname in English |
surname_th | String | Surname in Thai |
Code Examples
Python
import requests
url = "https://api.iapp.co.th/thai-national-id-card-with-signature/front"
api_key = "YOUR_API_KEY"
# Prepare the image file
files = {
'file': ('idcard.jpg', open('path/to/idcard.jpg', 'rb'), 'image/jpeg')
}
# Add API key to headers
headers = {
'apikey': api_key
}
# Make the request
response = requests.post(url, headers=headers, files=files)
# Print results
print(response.json())
JavaScript
// Using Fetch API
const formData = new FormData()
formData.append("file", fileInput.files[0])
fetch("https://api.iapp.co.th/thai-national-id-card-with-signature/front", {
method: "POST",
headers: {
apikey: "YOUR_API_KEY",
},
body: formData,
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.error("Error:", error))
PHP
<?php
$curl = curl_init();
$file = new CURLFile('path/to/idcard.jpg', 'image/jpeg', 'idcard.jpg');
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.iapp.co.th/thai-national-id-card-with-signature/front',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'apikey: YOUR_API_KEY'
],
CURLOPT_POSTFIELDS => [
'file' => $file
]
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
Swift
import Foundation
let url = URL(string: "https://api.iapp.co.th/thai-national-id-card-with-signature/front")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
let boundary = "Boundary-\(UUID().uuidString)"
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "apikey")
let imageData = try! Data(contentsOf: URL(fileURLWithPath: "path/to/idcard.jpg"))
var body = Data()
body.append("--\(boundary)\r\n")
body.append("Content-Disposition: form-data; name=\"file\"; filename=\"idcard.jpg\"\r\n")
body.append("Content-Type: image/jpeg\r\n\r\n")
body.append(imageData)
body.append("\r\n--\(boundary)--\r\n")
request.httpBody = body
URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
let json = try? JSONSerialization.jsonObject(with: data)
print(json ?? "")
}
}.resume()
Kotlin
import okhttp3.*
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart(
"file",
"idcard.jpg",
File("path/to/idcard.jpg")
.asRequestBody("image/jpeg".toMediaTypeOrNull())
)
.build()
val request = Request.Builder()
.url("https://api.iapp.co.th/thai-national-id-card-with-signature/front")
.addHeader("apikey", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
Java
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
public class IDCardAPI {
public static void main(String[] args) throws IOException {
String boundary = "Boundary-" + System.currentTimeMillis();
URL url = new URL("https://api.iapp.co.th/thai-national-id-card-with-signature/front");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
conn.setRequestProperty("apikey", "YOUR_API_KEY");
try (OutputStream os = conn.getOutputStream()) {
File file = new File("path/to/idcard.jpg");
writeMultipartFile(os, "file", file, boundary);
os.write(("--" + boundary + "--\r\n").getBytes());
}
try (BufferedReader br = new BufferedReader(
new InputStreamReader(conn.getInputStream()))) {
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}
}
private static void writeMultipartFile(OutputStream os, String name, File file, String boundary)
throws IOException {
os.write(("--" + boundary + "\r\n").getBytes());
os.write(("Content-Disposition: form-data; name=\"" + name + "\"; filename=\"" +
file.getName() + "\"\r\n").getBytes());
os.write("Content-Type: image/jpeg\r\n\r\n".getBytes());
try (FileInputStream fis = new FileInputStream(file)) {
byte[] buffer = new byte[4096];
int length;
while ((length = fis.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
os.write("\r\n".getBytes());
}
}
}
Dart
import 'package:http/http.dart' as http;
Future<void> uploadIDCard() async {
var url = Uri.parse('https://api.iapp.co.th/thai-national-id-card-with-signature/front');
var request = http.MultipartRequest('POST', url);
request.headers['apikey'] = 'YOUR_API_KEY';
request.files.add(
await http.MultipartFile.fromPath(
'file',
'path/to/idcard.jpg',
),
);
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
Error Codes
ID Card Detection Codes
Status Code | Status Message | Description |
---|---|---|
1 | pass | Confident about the content read |
0 | manual check | Not confident about content, needs manual check |
Signature Detection Codes
Status Code | Status Message | Description |
---|---|---|
1 | pass | Signature found on paper |
0 | manual check | Signature not found or needs verification |
API Response Codes
Status Code | Status Message | Description |
---|---|---|
200 | SUCCESS | Request successful |
404 | REQUESTED_URL_NOT_FOUND | API route not found |
405 | METHOD_NOT_ALLOWED | Incorrect HTTP method |
413 | IMAGE_FILE_IS_TOO_LARGE | File exceeds 2MB limit |
414 | NO_FILE_ATTACHED | No file in request |
415 | INVALID_IMAGE_SIZE | Image dimensions invalid |
420 | NO_ID_CARD_FOUND | ID card not detected in image |
421 | IMAGE_ERROR_UNSUPPORTED_FORMAT | Unsupported or corrupted image format |
422 | INVALID_IMAGE_SIZE | Image size requirements not met |
427 | LONG_TIME_TO_PROCESS | Server processing timeout |
428 | LONG_TIME_TO_REQUEST | Queue timeout |
560 | SERVER_IS_BUSY | Server overloaded, retry needed |
563 | ID_CARD_API_NOT_SUPPORT_THIS_IMAGE | Processing error |
Best Practices
-
Image Quality
- Ensure good lighting
- Avoid blurry images
- Keep ID card clearly visible
-
Processing
- Check reason codes in response
- Validate extracted information
- Handle errors appropriately
-
Security
- Keep API keys secure
- Validate input files
- Follow data protection guidelines
Accuracy & Performance
Overall Accuracy
- Text extraction accuracy: 98.13% at character level
- Signature detection accuracy: 96.5%
- Field-specific accuracy varies by content type
Processing Speed
- Average: 1-3 seconds per image
- Factors affecting speed:
- Image resolution
- File size
- Server load
- Network conditions
Factors Affecting Accuracy
-
Image Quality
- Resolution (minimum 300 DPI recommended)
- Lighting conditions
- Focus clarity
- Color contrast
-
Document Condition
- Physical damage or wear
- Reflections or glare
- Text clarity and legibility
- Signature visibility
-
Capture Conditions
- Camera angle
- Background noise
- Shadow effects
- Motion blur
History
Version | Release Date | Key Features |
---|---|---|
1.0 | 2023 | Initial Release with Signature Detection |
Pricing
AI API Service Name | Endpoint | IC Per Minute | On-Premise |
---|---|---|---|
Photographed Copy of Thai National ID Card OCR [v1.0] | iapp-photographed-copy-idcard-ocr | 1.25 IC/Minute | Contact |