🧾 Thai Receipt OCR 🆕
🧾 ใบเสร็จรับเงิน / ใบแจ้งหนี้ / ใบวางบิล / ใบกำกับภาษี
Welcome to the Thai Receipt OCR API, an AI-powered solution developed by iApp Technology Co., Ltd. for extracting data from Thai receipts and invoices. This documentation will help you integrate and use our OCR service effectively.
Example Images (Click to try)

Demo key is limited to 10 requests per day per IP
Click here to get your API key
Getting Started
-
Prerequisites
- An API key from iApp Technology
- Thai / English receipt using printed or handwritten images
- Supported file formats: JPEG, JPG, PNG, HEIC, HEIF, 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:
- Invoice details (type, ID, date, book number)
- Issuer information (name, address, tax ID, contact)
- Customer information (name, address, tax ID, contact)
- Line item details (item code, name, quantity, unit price, total)
- Financial summary (subtotal, discount, VAT, grand total)
- 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
- Detailed field extraction including:
-
Security & Compliance
- GDPR and PDPA compliant
- Secure API endpoints
- No data retention after processing
Our API is designed to handle various receipt formats and layouts commonly used in Thailand, from simple retail receipts to formal tax invoices. The post-processing AI model is trained to understand Thai receipt structures and can reliably extract information even from noisy or poorly scanned documents.
Example
Here's a sample receipt and its extracted data:

Request:
cURL
curl -X POST "https://api.iapp.co.th/ocr/v3/receipt/file" \
-H "apikey: YOUR_API_KEY" \
-F "file=@/path/to/receipt.jpg" \
-F "return_image=false" \
-F "return_ocr=false"
Please visit iApp AI Portal to view your existing API key or request a new one.
Response:
{
"message": "success",
"processed": {
"invoiceType": "ใบเสร็จรับเงิน/ใบกำกับภาษีอย่างย่อ",
"invoiceBook": null,
"invoiceID": "4504RC112566/004044",
"invoiceDate": "27/11/2566",
"issuerName": "หจก.บุญรอดคอฟฟี (ตลาดรัตนบุรี)",
"issuerTaxID": "0323560000723",
"items": [
{
"itemNo": 1,
"itemName": "ชาเขียวนม ร้อน ขนาดใหญ่",
"itemUnit": 1,
"itemUnitCost": 60.0,
"itemTotalCost": 60.0
}
],
"totalCost": 60.0,
"discount": 0.0,
"totalCostAfterDiscount": 60.0,
"vat": 3.93,
"grandTotal": 60.0
},
"process_ms": 6821
}
Features & Capabilities
Core Features
-
Document Processing
- High accuracy text extraction and field recognition
- Thai / English language supported.
- Printed / Handwritten supported.
- Fast processing time of 5-10 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
-
Data Extraction
- Flexible JSON response format with detailed field extraction
Supported Fields
Field | Type | Description |
---|---|---|
invoiceType | String | Title or type of invoice |
invoiceBook | String | Book number of invoice |
invoiceID | String | ID number of invoice |
invoiceDate | String | Date of invoice issuance |
purchaseOrderID | String | ID number of linked purchase order |
issuerName | String | Name of invoice issuer |
issuerAddress | String | Address of invoice issuer |
issuerTaxID | String | Tax ID of invoice issuer |
issuerPhone | String | Contact phone of invoice issuer |
customerName | String | Name of customer |
customerAddress | String | Address of customer |
customerTaxID | String | Tax ID of customer |
customerPhone | String | Contact phone of customer |
items | Array | Array of line items with details below |
- itemNo | String | Item sequence number |
- itemCode | String | Product/service code |
- itemName | String | Product/service name |
- itemUnit | Number | Quantity of item |
- itemUnitCost | Number | Cost per unit |
- itemTotalCost | Number | Total cost for this item |
totalCost | Number | Sum of all item costs |
discount | Number | Discount amount if applicable |
totalCostAfterDiscount | Number | Total cost after applying discount |
vat | Number | Value Added Tax amount (7%) |
grandTotal | Number | Final total amount including VAT |
Note: All currency values are rounded to two decimal places.
API Reference
Welcome to the Thai Receipt OCR API, a powerful tool for converting Thai receipts and invoices into structured JSON data. This API leverages advanced OCR and AI technologies to extract key information such as invoice details, issuer and customer data, line items, and financial totals.
Recognizing Receipt
There are two endpoints available for processing receipts:
1. File Upload
POST https://api.iapp.co.th/ocr/v3/receipt/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 | Receipt 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) |
Supported File Types
- Images: JPEG, PNG
- Documents: PDF (single or multiple pages)
Response Format
{
"message": "success",
"raw": {
"image": "string", // Base64 encoded, only if return_image=true
"text": "string" // Only if return_ocr=true
},
"processed": {
"invoiceType": "string",
"invoiceBook": "string",
"invoiceID": "string",
"invoiceDate": "string",
"purchaseOrderID": "string",
"issuerName": "string",
"issuerAddress": "string",
"issuerTaxID": "string",
"issuerPhone": "string",
"customerName": "string",
"customerAddress": "string",
"customerTaxID": "string",
"customerPhone": "string",
"items": [
{
"itemNo": "string",
"itemCode": "string",
"itemName": "string",
"itemUnit": "number",
"itemUnitCost": "number",
"itemTotalCost": "number"
}
],
"totalCost": "number",
"discount": "number",
"totalCostAfterDiscount": "number",
"vat": "number",
"grandTotal": "number"
},
"template": "receipt",
"iapp": "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 |
2. Base64 Image
POST https://api.iapp.co.th/ocr/v3/receipt/base64
Request Headers
Name | Type | Required | Description |
---|---|---|---|
apikey | string | Yes | Your API key |
Request Body
You can send the base64 data either as JSON or form data:
JSON Format:
{
"base64_string": "string", // Base64 encoded image data
"return_image": false, // Optional
"return_ocr": false // Optional
}
Form Data Format:
Parameter | Type | Required | Description |
---|---|---|---|
base64_string | string | Yes | Base64 encoded image data |
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
Same as file upload endpoint
Code Examples
Python (File Upload)
import requests
apiKey = 'YOUR_API_KEY'
filePath = '/path/to/receipt.jpg'
url = "https://api.iapp.co.th/ocr/v3/receipt/file"
headers = {'apikey': apiKey}
files = {'file': ('receipt.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())
Python (Base64)
import requests
import base64
apiKey = 'YOUR_API_KEY'
url = "https://api.iapp.co.th/ocr/v3/receipt/base64"
# Read image file and convert to base64
with open('/path/to/receipt.jpg', 'rb') as image_file:
base64_string = base64.b64encode(image_file.read()).decode()
headers = {
'apikey': apiKey,
'Content-Type': 'application/json'
}
data = {
'base64_string': base64_string,
'return_image': False,
'return_ocr': False
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
Javascript (File Upload)
const axios = require("axios")
const FormData = require("form-data")
const fs = require("fs")
const apiKey = "YOUR_API_KEY"
const filePath = "/path/to/receipt.jpg"
const url = "https://api.iapp.co.th/ocr/v3/receipt/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
}
Javascript (Base64)
const axios = require("axios")
const fs = require("fs")
const apiKey = "YOUR_API_KEY"
const url = "https://api.iapp.co.th/ocr/v3/receipt/base64"
// Read image file and convert to base64
const base64String = fs.readFileSync('/path/to/receipt.jpg', {encoding: 'base64'})
const data = {
base64_string: base64String,
return_image: false,
return_ocr: false
}
try {
const response = await axios.post(url, data, {
headers: {
'Content-Type': 'application/json',
'apikey': apiKey
}
})
return response.data
} catch (error) {
throw error
}
PHP (File Upload)
$url = 'https://api.iapp.co.th/ocr/v3/receipt/file';
$apiKey = 'YOUR_API_KEY';
$filePath = '/path/to/receipt.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;
PHP (Base64)
<?php
$url = 'https://api.iapp.co.th/ocr/v3/receipt/base64';
$apiKey = 'YOUR_API_KEY';
$filePath = '/path/to/receipt.jpg';
// Read image file and convert to base64
$base64String = base64_encode(file_get_contents($filePath));
$data = array(
'base64_string' => $base64String,
'return_image' => false,
'return_ocr' => false
);
$headers = array(
'Content-Type: application/json',
'apikey: ' . $apiKey
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Swift (File Upload)
import Foundation
let url = URL(string: "https://api.iapp.co.th/ocr/v3/receipt/file")!
let filePath = "/path/to/receipt.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=\"receipt.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()
Swift (Base64)
import Foundation
let url = URL(string: "https://api.iapp.co.th/ocr/v3/receipt/base64")!
let filePath = "/path/to/receipt.jpg"
let apiKey = "YOUR_API_KEY"
// Read image file and convert to base64
guard let imageData = try? Data(contentsOf: URL(fileURLWithPath: filePath)) else {
print("Error reading file")
return
}
let base64String = imageData.base64EncodedString()
let parameters: [String: Any] = [
"base64_string": base64String,
"return_image": false,
"return_ocr": false
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue(apiKey, forHTTPHeaderField: "apikey")
request.httpBody = try? JSONSerialization.data(withJSONObject: parameters)
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 (File Upload)
import okhttp3.*
import java.io.File
val client = OkHttpClient()
val apiKey = "YOUR_API_KEY"
val filePath = "/path/to/receipt.jpg"
val url = "https://api.iapp.co.th/ocr/v3/receipt/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())
}
}
})
Kotlin (Base64)
import okhttp3.*
import java.io.File
import android.util.Base64
import org.json.JSONObject
fun processBase64Image() {
val client = OkHttpClient()
val apiKey = "YOUR_API_KEY"
val filePath = "/path/to/receipt.jpg"
val url = "https://api.iapp.co.th/ocr/v3/receipt/base64"
// Read file and convert to base64
val file = File(filePath)
val bytes = file.readBytes()
val base64String = Base64.encodeToString(bytes, Base64.DEFAULT)
val json = JSONObject()
json.put("base64_string", base64String)
json.put("return_image", false)
json.put("return_ocr", false)
val requestBody = RequestBody.create(
MediaType.parse("application/json"),
json.toString()
)
val request = Request.Builder()
.url(url)
.post(requestBody)
.addHeader("Content-Type", "application/json")
.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 (File Upload)
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/receipt/file";
String filePath = "/path/to/receipt.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());
}
});
}
}
Java (Base64)
import okhttp3.*;
import java.io.File;
import java.io.IOException;
import java.util.Base64;
import java.nio.file.Files;
import org.json.JSONObject;
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/receipt/base64";
String filePath = "/path/to/receipt.jpg";
try {
// Read file and convert to base64
byte[] fileContent = Files.readAllBytes(new File(filePath).toPath());
String base64String = Base64.getEncoder().encodeToString(fileContent);
JSONObject json = new JSONObject();
json.put("base64_string", base64String);
json.put("return_image", false);
json.put("return_ocr", false);
RequestBody requestBody = RequestBody.create(
MediaType.parse("application/json"),
json.toString()
);
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.addHeader("Content-Type", "application/json")
.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());
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
Dart (File Upload)
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
String url = 'https://api.iapp.co.th/ocr/v3/receipt/file';
String filePath = '/path/to/receipt.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}');
}
}
Dart (Base64)
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
void main() async {
String url = 'https://api.iapp.co.th/ocr/v3/receipt/base64';
String filePath = '/path/to/receipt.jpg';
String apiKey = 'YOUR_API_KEY';
try {
// Read file and convert to base64
File file = File(filePath);
List<int> fileBytes = await file.readAsBytes();
String base64String = base64Encode(fileBytes);
Map<String, dynamic> data = {
'base64_string': base64String,
'return_image': false,
'return_ocr': false
};
var response = await http.post(
Uri.parse(url),
headers: {
'Content-Type': 'application/json',
'apikey': apiKey
},
body: jsonEncode(data)
);
if (response.statusCode == 200) {
print(response.body);
} else {
print('Error: ${response.statusCode}');
}
} catch (e) {
print('Error: $e');
}
}
Limitations & Best Practices
Limitations
- Maximum file size: 10MB
- Supported languages: Thai
- PDF files: Up to 10 pages
- 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 10,000 Thai receipts:
Field Type | Accuracy (%) | Notes |
---|---|---|
Invoice Numbers | 99.2% | Including tax invoice numbers |
Amounts | 99.5% | Currency values and totals |
Dates | 98.7% | Various Thai date formats |
Line Items | 97.8% | Product details and prices |
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
-
Receipt 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 | Endpoint | Pricing | On-Premise |
---|---|---|---|
Receipt OCR [v1.0] | receipt-ocr | 1 IC/Page | Contact |