Skip to main content

🪪✏️ Photographed Thai National ID Card With Signature Detection

🪪✏️ บริการ AI แกะข้อความจากรูปสำเนาบัตรประชาชน

Version Status

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.

Try Demo

Visit our API Portal to test the Photographed Thai National ID Card With Signature Detectiont OCR API with your own images.

Getting Started

  1. 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
  2. Quick Start

    • Processing time: 1-3 seconds per image
    • Automatic card detection and cropping
    • Support for both color and black & white copies
  3. 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
  4. Security & Compliance

    • GDPR and PDPA compliant
    • No data retention after processing
How to get API Key?

Please visit API Portal to view your existing API key or request a new one.

Example

Thai National ID Card Example on Photograph Paper with Signature Signed (Front side)
Remark

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

FieldTypeDescription
address_districtStringDistrict Name
address_fullStringFull Address
address_numberStringHome Address
address_postal_codeStringPostal Code
address_provinceStringProvince Name
address_subdistrictStringSub District Name
date_of_birthStringDate of Birth in Thai
date_of_expireStringDate of Expiry in Thai
file_name_id_cardStringFilename of image
fullname_enStringName and Surname in English
fullname_thStringName and Surname in Thai
init_enStringName Title in English
init_thStringName Title in Thai
name_enStringName in English
name_thStringName in Thai
national_idStringNational ID Number
process_timeFloatProcessing Time (sec.)
reason_code_apiIntegerResponse Status Code
reason_code_id_cardInteger0 - ID Card Not Found in Image, 1 - ID Card Found in Image
reason_code_id_card_national_idInteger0 - National ID Number Not Found, 1 - National ID Number Found
reason_codename_id_cardIntegerCode explaining the reason_code_id_card_national_id. (TODO)
reason_code_id_card_signatureInteger0 - Signature Not Found on paper, 1 - Signature Found on paper
reason_codename_id_card_signatureIntegerCode explaining reason_code_id_card_signature. (TODO)
request_idStringRequest ID from API Gateway
surname_enStringSurname in English
surname_thStringSurname 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 CodeStatus MessageDescription
1passConfident about the content read
0manual checkNot confident about content, needs manual check

Signature Detection Codes

Status CodeStatus MessageDescription
1passSignature found on paper
0manual checkSignature not found or needs verification

API Response Codes

Status CodeStatus MessageDescription
200SUCCESSRequest successful
404REQUESTED_URL_NOT_FOUNDAPI route not found
405METHOD_NOT_ALLOWEDIncorrect HTTP method
413IMAGE_FILE_IS_TOO_LARGEFile exceeds 2MB limit
414NO_FILE_ATTACHEDNo file in request
415INVALID_IMAGE_SIZEImage dimensions invalid
420NO_ID_CARD_FOUNDID card not detected in image
421IMAGE_ERROR_UNSUPPORTED_FORMATUnsupported or corrupted image format
422INVALID_IMAGE_SIZEImage size requirements not met
427LONG_TIME_TO_PROCESSServer processing timeout
428LONG_TIME_TO_REQUESTQueue timeout
560SERVER_IS_BUSYServer overloaded, retry needed
563ID_CARD_API_NOT_SUPPORT_THIS_IMAGEProcessing error

Best Practices

  1. Image Quality

    • Ensure good lighting
    • Avoid blurry images
    • Keep ID card clearly visible
  2. Processing

    • Check reason codes in response
    • Validate extracted information
    • Handle errors appropriately
  3. 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

  1. Image Quality

    • Resolution (minimum 300 DPI recommended)
    • Lighting conditions
    • Focus clarity
    • Color contrast
  2. Document Condition

    • Physical damage or wear
    • Reflections or glare
    • Text clarity and legibility
    • Signature visibility
  3. Capture Conditions

    • Camera angle
    • Background noise
    • Shadow effects
    • Motion blur

History

VersionRelease DateKey Features
1.02023Initial Release with Signature Detection

Pricing

AI API Service NameEndpointIC Per MinuteOn-Premise
Photographed Copy of Thai National ID Card OCR [v1.0]iapp-photographed-copy-idcard-ocr1.25 IC/MinuteContact