📄 Thai Civil Registration Certificate OCR 🆕
📄 แบบรับรองรายการทะเบียนราษฎร
Welcome to the Thai Civil Registration Certificate OCR API, an AI-powered solution developed by iApp Technology Co., Ltd. for extracting data from Thai civil registration documents. This documentation will help you integrate and use our OCR service effectively.
Getting Started
-
Prerequisites
- An API key from iApp Technology
- Thai civil registration document images
- Supported file formats: JPEG, JPG, PNG, PDF
- Maximum file size: 10MB
-
Quick Start
- Fast processing (5-10 seconds per document)
- High accuracy text extraction
- Support for multiple file formats
-
Key Features
- Detailed field extraction including:
- Personal information (name, ID, gender, nationality)
- Birth details (date, age)
- Family information (parents' names and nationalities)
- Residential details (address, status, registration)
- Document metadata (dates, remarks, registrar info)
- Support for single-page documents
- Option to return original OCR text and processed images
- Flexible JSON response format
- Detailed field extraction including:
-
Security & Compliance
- GDPR and PDPA compliant
- Secure API endpoints
- No data retention after processing
Please visit API Portal to view your existing API key or request a new one.
Example
Here's a sample civil registration certificate and its extracted data:
Request:
cURL
curl -X POST https://api.iapp.co.th/ocr/v3/civil-registeration-certificate/file \
-H apikey: YOUR_API_KEY \
-F file=@/path/to/document.jpg \
-F return_image=false \
-F return_ocr=false
Response:
{
"message": "success",
"processed": {
"header": "(ท้องถิ่นเขตยานนาวา) ท.ร. 14/1",
"title": "แบบรับรองรายการทะเบียนราษฎร จากฐานข้อมูลการทะเบียน\nสำนักทะเบียนกลาง กรมการปกครอง กระทรวงมหาดไทย",
"nationalIdNumber": "X-XXXX-XXXXX-XX-X",
"houseRegistrationNumber": "XXXX-XXXXXX-X",
"name": "นายสXXXXX XXXXXXXXXXX",
"gender": "ชาย",
"nationality": "ไทย",
"dateOfBirth": "8 XXXXXXX 2498",
"age": 64,
"residentialStatus": "เจ้าบ้าน",
"mothersName": "XXXXX",
"mothersNationality": "จีน",
"fathersName": "XXXXX",
"fathersNationality": "จีน",
"address": "XXX XXXXXXX XXX แขวงตลิ่งชัน เขตตลิ่งชัน กรุงเทพมหานคร",
"registrationOffice": "ท้องถิ่นเขตตลิ่งชัน",
"moveInDate": "28 เดือน XXXXXXX พ.ศ. 2537",
"additionalNotes": "บุคคลนี้ถูกจำหน่ายชื่อจากทะเบียนบ้านเนื่องจากตาย เมื่อ 14 XXXXXXXX 2562",
"remarks": "คัดรับรองตามคำร้องที่ ๗๙๐๘/๒๕๖๗ ลงวันที่ ๒ กันยายน ๒๕๖๗",
"lastUpdated": "วันที่ 2 เดือน กันยายน พ.ศ. 2567",
"footer": {
"text": "รับรองว่าเป็นรายการจากฐานข้อมูลการทะเบียนราษฎร",
"date": "2 เดือน กันยายน พ.ศ. 2567",
"registrar": "นายอิทธิพัทธ์ เล็กชลยุทธ"
}
},
"process_ms": 8115
}
Features & Capabilities
Core Features
-
Document Processing
- High accuracy text extraction and field recognition
- Thai language supported
- Printed document format supported
- Fast processing time of 5-10 seconds per document
- Multi-format support (JPEG, JPG, PNG, PDF)
- Single-page document handling
- Option to return original OCR text and processed images
- GDPR and PDPA compliant processing
-
Data Extraction
- Flexible JSON response format with detailed field extraction
Supported Fields
Field | Type | Description |
---|---|---|
header | String | Document type and form number |
title | String | Official document title |
nationalIdNumber | String | 13-digit Thai national ID number |
houseRegistrationNumber | String | House registration code |
name | String | Full name of the person |
gender | String | Gender of the person |
nationality | String | Nationality of the person |
dateOfBirth | String | Date of birth in Thai format |
age | Number | Current age |
residentialStatus | String | Status in the household |
mothersName | String | Mother's full name |
mothersNationality | String | Mother's nationality |
fathersName | String | Father's full name |
fathersNationality | String | Father's nationality |
address | String | Current residential address |
registrationOffice | String | Name of registration office |
moveInDate | String | Date of moving to current address |
additionalNotes | String | Additional information |
remarks | String | Official remarks |
lastUpdated | String | Last update date |
footer | Object | Contains certification text, date and registrar info |
API Reference
Recognizing Civil Registration Certificate
This endpoint processes a civil registration certificate image or PDF and returns the extracted data in a structured format.
POST https://api.iapp.co.th/ocr/v3/civil-registeration-certificate/file
Request Headers
Name | Type | Required | Description |
---|---|---|---|
apikey | string | Yes | Your API key |
Request Body (multipart/form-data)
Parameter | Type | Required | Description |
---|---|---|---|
file | file | Yes | Document image (JPEG, PNG) or PDF document |
return_image | boolean | No | Include base64 encoded image in response (default: false) |
return_ocr | boolean | No | Include raw OCR text in response (default: false) |
Response Format
{
"message": "success",
"raw": {
"image": "string", // Base64 encoded, only if return_image=true
"text": "string" // Only if return_ocr=true
},
"processed": {
"header": "string",
"title": "string",
"nationalIdNumber": "string",
"houseRegistrationNumber": "string",
"name": "string",
"gender": "string",
"nationality": "string",
"dateOfBirth": "string",
"age": "number",
"residentialStatus": "string",
"mothersName": "string",
"mothersNationality": "string",
"fathersName": "string",
"fathersNationality": "string",
"address": "string",
"registrationOffice": "string",
"moveInDate": "string",
"additionalNotes": "string",
"remarks": "string",
"lastUpdated": "string",
"footer": {
"text": "string",
"date": "string",
"registrar": "string"
}
},
"process_ms": "number"
}
Error Handling
Status | Code | Description |
---|---|---|
400 | BAD_REQUEST | Invalid parameters or file format |
401 | UNAUTHORIZED | Invalid or missing API key |
404 | NOT_FOUND | Invalid endpoint |
500 | INTERNAL_SERVER_ERROR | Processing failed |
Code Examples
Python
import requests
apiKey = 'YOUR_API_KEY'
filePath = '/path/to/civil-registeration-certificate.jpg'
url = "https://api.iapp.co.th/ocr/v3/civil-registeration-certificate/file"
headers = {'apikey': apiKey}
files = {'file': ('civil-registeration-certificate.jpg', open(filePath, 'rb'), 'image/jpeg')}
data = {'return_image': 'false', 'return_ocr': 'false'}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())
Javascript
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const apiKey = 'YOUR_API_KEY';
const filePath = '/path/to/civil-registeration-certificate.jpg';
const url = 'https://api.iapp.co.th/ocr/v3/civil-registeration-certificate/file';
const form = new FormData();
form.append('file', fs.createReadStream(filePath));
form.append('return_image', 'false');
form.append('return_ocr', 'false');
try {
const response = await axios.post(
url,
form,
{
headers: {
...form.getHeaders(),
'apikey': apiKey
}
}
);
return response.data;
} catch (error) {
throw error;
}
PHP
$url = 'https://api.iapp.co.th/ocr/v3/civil-registeration-certificate/file';
$apiKey = 'YOUR_API_KEY';
$filePath = '/path/to/civil-registeration-certificate.jpg';
$headers = array(
'apikey: ' . $apiKey
);
$postFields = array(
'file' => new CURLFile($filePath),
'return_image' => 'false',
'return_ocr' => 'false'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Swift
import Foundation
let url = URL(string: "https://api.iapp.co.th/ocr/v3/civil-registeration-certificate/file")!
let filePath = "/path/to/civil-registeration-certificate.jpg"
let apiKey = "YOUR_API_KEY"
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue(apiKey, forHTTPHeaderField: "apikey")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"file\"; filename=\"civil-registeration-certificate.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: image/jpeg\r\n\r\n".data(using: .utf8)!)
body.append(try! Data(contentsOf: URL(fileURLWithPath: filePath)))
body.append("\r\n--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"return_image\"\r\n\r\nfalse\r\n".data(using: .utf8)!)
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"return_ocr\"\r\n\r\nfalse\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data, error == nil else {
print("Error: \(error?.localizedDescription ?? "Unknown error")")
return
}
print(String(data: data, encoding: .utf8)!)
}
task.resume()
Kotlin
import okhttp3.*
import java.io.File
val client = OkHttpClient()
val apiKey = "YOUR_API_KEY"
val filePath = "/path/to/civil-registeration-certificate.jpg"
val url = "https://api.iapp.co.th/ocr/v3/civil-registeration-certificate/file"
val file = File(filePath)
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("file", file.name, RequestBody.create(MediaType.parse("image/jpeg"), file))
.addFormDataPart("return_image", "false")
.addFormDataPart("return_ocr", "false")
.build()
val request = Request.Builder()
.url(url)
.post(requestBody)
.addHeader("apikey", apiKey)
.build()
client.newCall(request).enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
e.printStackTrace()
}
override fun onResponse(call: Call, response: Response) {
response.use {
if (!response.isSuccessful) throw IOException("Unexpected code $response")
println(response.body()?.string())
}
}
})
Java
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
OkHttpClient client = new OkHttpClient();
String apiKey = "YOUR_API_KEY";
String url = "https://api.iapp.co.th/ocr/v3/civil-registeration-certificate/file";
String filePath = "/path/to/civil-registeration-certificate.jpg";
File file = new File(filePath);
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("file", file.getName(), RequestBody.create(MediaType.parse("image/jpeg"), file))
.addFormDataPart("return_image", "false")
.addFormDataPart("return_ocr", "false")
.build();
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.addHeader("apikey", apiKey)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
System.out.println(response.body().string());
}
});
}
}
Dart
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
String url = 'https://api.iapp.co.th/ocr/v3/civil-registeration-certificate/file';
String filePath = '/path/to/civil-registeration-certificate.jpg';
String apiKey = 'YOUR_API_KEY';
void main() async {
var url = Uri.parse(url);
var request = http.MultipartRequest('POST', url)
..headers['apikey'] = apiKey
..files.add(await http.MultipartFile.fromPath('file', filePath))
..fields['return_image'] = 'false'
..fields['return_ocr'] = 'false';
var response = await request.send();
if (response.statusCode == 200) {
var responseData = await response.stream.bytesToString();
print(responseData);
} else {
print('Error: ${response.statusCode}');
}
}
Limitations & Best Practices
Limitations
- Maximum file size: 10MB
- Supported language: Thai
- PDF files: Single page only
- Rate limit: 10 requests per second per API key
Best Practices
- Ensure good image quality for optimal results
- Use JPEG or PNG format for images
- Implement error handling for failed requests
- Cache responses when processing the same document multiple times
- Set appropriate timeouts for large files
Accuracy & Performance
Overall Accuracy
Based on our benchmark dataset of 1,000 Thai civil registration certificates:
Field Type | Accuracy (%) | Notes |
---|---|---|
ID Numbers | 99.5% | National ID and house registration numbers |
Names | 99.2% | Person and parent names |
Dates | 98.7% | Birth dates and registration dates |
Addresses | 97.8% | Full address details |
Overall | 98.8% | Weighted average |
Processing Speed
- Average processing time: 5-10 seconds
- 95th percentile: 12 seconds
- Maximum processing time: 15 seconds
Factors Affecting Accuracy
-
Image Quality
- Resolution (minimum 300 DPI recommended)
- Lighting conditions
- Image focus and clarity
-
Document Condition
- Physical damage
- Fading or wear
- Handwritten modifications
-
Document Format
- Standard formats: 99%+ accuracy
- Non-standard layouts: 95%+ accuracy
- Handwritten elements: 90%+ accuracy
History
Our model is continuously trained on new data to improve accuracy:
Version | Release Date | Accuracy | Key Improvements |
---|---|---|---|
3.0 | 2024-12-27 | 96.5% | Base version |
Pricing
AI API Service Name | IC Per Request | On-Premise |
---|---|---|
Thai Civil Registration Certificate OCR | 1 IC/Request | Contact |