Skip to main content

📄 Thai Tax Deduction Certificate OCR 🆕

📄 ใบรับรองการหักภาษี ณ ที่จ่ายของไทย / ใบรับรอง ภงด.

Version Status New

Welcome to the Thai Tax Deduction Certificate OCR API, an AI-powered solution developed by iApp Technology Co., Ltd. for extracting data from Thai tax deduction certificates. This documentation will help you integrate and use our OCR service effectively.

Getting Started

  1. Prerequisites

    • An API key from iApp Technology
    • Thai tax deduction certificate images
    • Supported file formats: JPEG, JPG, PNG, HEIC, HEIF, PDF
    • Maximum file size: 10MB
  2. Quick Start

    • Fast processing (5-10 seconds per document)
    • High accuracy text extraction
    • Support for multiple file formats
  3. Key Features

    • Detailed field extraction including:
      • Certificate details (ID, date)
      • Payer information (name, address, tax ID)
      • Payee information (name, address, tax ID)
      • Income details (type, amount, tax withheld)
      • Financial summary (total income, total tax withheld)
    • Support for both single-page and multi-page documents (PDF)
    • Option to return original OCR text and processed images
    • Flexible JSON response format with detailed field extraction
  4. Security & Compliance

    • GDPR and PDPA compliant
    • Secure API endpoints
    • No data retention after processing

Our API is designed to handle various tax deduction certificate formats and layouts commonly used in Thailand. The post-processing AI model is trained to understand Thai tax document structures and can reliably extract information even from noisy or poorly scanned documents.

Example

Here's a sample Thai tax deduction certificate and its extracted data:

Thai Tax Deduction Certificate Example

Request:

cURL

curl -X POST https://api.iapp.co.th/ocr/v3/tax-deduction-certificate-prd/file \
-H apikey: YOUR_API_KEY \
-F file=@/path/to/certificate.jpg \
-F return_image=false \
-F return_ocr=false
How to get API Key?

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

Response:

{
"message": "success",
"raw": {},
"processed": {
"documentType": "หนังสือรับรองการหักภาษี ณ ที่จ่าย",
"documentForm": "ภ.ง.ด.3",
"bookNumber": "TX63XXXX",
"documentNumber": null,
"taxDeductor": {
"name": "บริษัท XXXXXXXXXXXXXXXXXXXX จำกัด",
"taxId": "010XXXXXXXX64",
"address": "XXXX XXXXXX XXXXXXXX เขตจอมทอง กรุงเทพมหานคร 10150"
},
"taxpayer": {
"name": "นายXXXXX เป็นตัวอย่าง",
"taxId": "31XXXXXXXX123",
"address": "XXXX XXXXXX XXXXXXXX เขตสาทร กรุงเทพมหานคร"
},
"paymentTypes": [
{
"paymentDate": "02/09/63",
"amount": XXXXX.XX,
"withholdingTax": XXXX.XX
}
],
"totalAmount": XXXXX.XX,
"totalTax": XXXX.XX,
"socialSecurity": {
"amount": null,
"year": null
},
"taxPayerMethod": "ออกภาษีให้ตลอดไป"
},
"template": "tax-deduction-certificate-prd",
"iapp": {
"page": 0,
"char": 3260
},
"process_ms": 46649
}

Features & Capabilities

Core Features

  1. Document Processing

    • High accuracy text extraction and field recognition
    • Thai language support
    • Fast processing time of 25-30 seconds per document
    • Multi-format support (JPEG, JPG, PNG, HEIC, HEIF, PDF)
    • Multi-page document handling
    • Option to return original OCR text and processed images
    • GDPR and PDPA compliant processing
  2. Data Extraction

    • Flexible JSON response format with detailed field extraction

Supported Fields

FieldTypeDescription
documentTypeStringType of tax document
documentFormStringForm type (ภ.ง.ด.1ก, ภ.ง.ด.1ก พิเศษ, ภ.ง.ด.2, ภ.ง.ด.3, ภ.ง.ด.2ก, ภ.ง.ด.3ก, ภ.ง.ด.53)
bookNumberStringBook number of document
documentNumberStringDocument number
taxDeductor.nameStringName of tax deductor
taxDeductor.taxIdStringTax ID of tax deductor
taxDeductor.addressStringAddress of tax deductor
taxpayer.nameStringName of taxpayer
taxpayer.taxIdStringTax ID of taxpayer
taxpayer.addressStringAddress of taxpayer
paymentTypes[].paymentDateStringDate of payment
paymentTypes[].amountNumberPayment amount
paymentTypes[].withholdingTaxNumberWithholding tax amount
totalAmountNumberTotal payment amount
totalTaxNumberTotal withholding tax amount
socialSecurity.amountNumberSocial security amount
socialSecurity.yearNumberSocial security year
taxPayerMethodStringTax payment method (หักภาษี ณ ที่จ่าย, ออกภาษีให้ตลอดไป, ออกภาษีให้ครั้งเดียว, อื่นๆ)

API Reference

Welcome to the Thai Tax Deduction Certificate OCR API, a powerful tool for converting Thai tax deduction certificates into structured JSON data. This API leverages advanced OCR and AI technologies to extract key information such as document details, tax deductor and taxpayer data, payment information, and tax amounts.

Recognizing Tax Deduction Certificate

This endpoint recognizes a tax deduction certificate image or PDF and returns the extracted data in a structured format.

POST https://api.iapp.co.th/ocr/v3/tax-deduction-certificate-prd/file

Request Headers

NameTypeRequiredDescription
apikeystringYesYour API key

Request Body (multipart/form-data)

ParameterTypeRequiredDescription
filefileYesTax certificate image (JPEG, PNG) or PDF document
return_imagebooleanNoInclude base64 encoded image in response (default: false)
return_ocrbooleanNoInclude raw OCR text in response (default: false)

Supported File Types

  • Images: JPEG, PNG, HEIC, HEIF
  • Documents: PDF (up to 10 pages)

Response Format

{
"message": "success",
"raw": {
"image": "string", // Base64 encoded, only if return_image=true
"text": "string" // Only if return_ocr=true
},
"processed": {
"documentType": "string",
"documentForm": "string",
"bookNumber": "string",
"documentNumber": "string",
"taxDeductor": {
"name": "string",
"taxId": "string",
"address": "string"
},
"taxpayer": {
"name": "string",
"taxId": "string",
"address": "string"
},
"paymentTypes": [
{
"paymentDate": "string",
"amount": "number",
"withholdingTax": "number"
}
],
"totalAmount": "number",
"totalTax": "number",
"socialSecurity": {
"amount": "number",
"year": "number"
},
"taxPayerMethod": "string"
},
"template": "tax-deduction-certificate-prd",
"iapp": {
"page": "number",
"char": "number"
},
"process_ms": "number"
}

Code Examples

Python

import requests
apiKey = 'YOUR_API_KEY'
filePath = '/path/to/tax-deduction-certificate-prd.jpg'
url = "https://api.iapp.co.th/ocr/v3/tax-deduction-certificate-prd/file"

headers = {'apikey': apiKey}
files = {'file': ('tax-deduction-certificate-prd.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/tax-deduction-certificate-prd.jpg';
const url = 'https://api.iapp.co.th/ocr/v3/tax-deduction-certificate-prd/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/tax-deduction-certificate-prd/file';
$apiKey = 'YOUR_API_KEY';
$filePath = '/path/to/tax-deduction-certificate-prd.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/tax-deduction-certificate-prd/file")!
let filePath = "/path/to/tax-deduction-certificate-prd.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=\"tax-deduction-certificate-prd.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/tax-deduction-certificate-prd.jpg"
val url = "https://api.iapp.co.th/ocr/v3/tax-deduction-certificate-prd/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/tax-deduction-certificate-prd/file";
String filePath = "/path/to/tax-deduction-certificate-prd.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/tax-deduction-certificate-prd/file';
String filePath = '/path/to/tax-deduction-certificate-prd.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: Up to 10 pages
  • Rate limit: 10 requests per second per API key

Best Practices

  1. Ensure good image quality for optimal results
  2. Use JPEG or PNG format for images
  3. Implement error handling for failed requests
  4. Cache responses when processing the same document multiple times
  5. Set appropriate timeouts for large files

Accuracy & Performance

Overall Accuracy

Based on our benchmark dataset of 5,000 Thai tax deduction certificates:

Field TypeAccuracy (%)Notes
Certificate Numbers99.5%Including certificate IDs
Amounts99.8%Currency values and totals
Dates99.0%Various Thai date formats
Tax IDs99.7%Both individual and corporate
Overall99.5%Weighted average

Processing Speed

  • Average processing time: 25-30 seconds
  • 95th percentile: 45 seconds
  • Maximum processing time: 67 seconds

Factors Affecting Accuracy

  1. Image Quality

    • Resolution (minimum 300 DPI recommended)
    • Lighting conditions
    • Image focus and clarity
  2. Document Condition

    • Physical damage
    • Fading or wear
    • Handwritten modifications
  3. 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:

VersionRelease DateAccuracyKey Improvements
3.02024-12-2799.5%Base version

Pricing

AI API Service NameIC Per RequestOn-Premise
Thai Tax Deduction Certificate OCR1 IC/RequestContact