💳 泰国信用卡账单 OCR
1 IC每页
欢迎使用泰国信用卡账单 OCR API,这是由艾艾普科技有限公司开发的一款由 AI 驱动的解决方案,用于从泰国信用卡账单中提取数据。本文档将帮助您有效地集成和使用我们的 OCR 服务。
试用演示!
入门指南
-
先决条件
- 来自艾艾普科技有限公司的 API 密钥
- 泰国信用卡账单图片
- 支持的文件格式:JPEG、JPG、PNG、HEIC、HEIF、PDF
- 最大文件大小:10MB
-
快速入门
- 快速处理(每个文档 5-10 秒)
- 高精度文本提取
- 支持多种文件格式
-
主要功能
- 详细的字段提取,包括:
- 账单详情(类型、日期、卡号)
- 持卡人信息(姓名)
- 银行信息(名称、地址、税号、联系方式)
- 交易详情(日期、描述、金额)
- 财务摘要(余额、付款、账款)
- 奖励积分信息
- 支持单页和多页文档(PDF)
- 可以选择返回原始 OCR 文本和处理后的图像
- 灵活的 JSON 响应格式,提供详细的字段提取
- 详细的字段提取,包括:
-
安全与合规
- 符合 GDPR 和 PDPA
- 安全的 API 端点
- 处理后不保留数据
示例
以下是信用卡账单示例及其提取的数据:
请求:
cURL
curl -X POST "https://api.iapp.co.th/ocr/v3/creditcard-statement/file" \
-H "apikey: YOUR_API_KEY" \
-F "file=@/path/to/creditcard-statement.jpg" \
-F "return_image=false" \
-F "return_ocr=false"
API 端点
| 端点 | 方法 | 描述 | 费用 |
|---|---|---|---|
/v3/store/ocr/creditcard-statement/ocr/v3/creditcard-statement | POST | 从泰国信用卡账单中提取数据 | 1 IC/页 |
响应:
{
"message": "success",
"processed": {
"statementType": "ใบแจ้งยอดบัญชีบัตรเครดิต",
"statementDate": "31/12/2566",
"dueDate": "25/01/2567",
"cardNumber": "4711-XXXX-XXXX-1234",
"cardHolderName": "นาย ทดสอบ ระบบ",
"bankName": "ธนาคารกสิกรไทย จำกัด (มหาชน)",
"bankAddress": "1 ซอยราษฎร์บูรณะ 27/1 ถนนราษฎร์บูรณะ แขวงราษฎร์บูรณะ เขตราษฎร์บูรณะ กรุงเทพฯ 10140",
"bankTaxID": "0107536000315",
"bankPhone": "02-888-8888",
"bankFax": "02-888-8888",
"creditLimit": 100000.0,
"closingDate": "31/12/2566",
"newBalancePayment": 15789.4,
"minimumPaymentDue": 789.47,
"interestRate": 16.0,
"paymentByDebitAccountNo": "XXX-X-XX789-X",
"transactions": [
{
"transactionDate": "20/12",
"postingDate": "21/12",
"description": "CHOKCHAI STEAK HOUSE PATHUMTHANI THA",
"foreignAmount": null,
"foreignCurrencyCode": null,
"amountTHB": 1089.0
}
],
"payments_adjustment_others": [
{
"transactionDate": "31/12",
"postingDate": "31/12",
"description": "PAYMENT RECEIVED, THK YOU",
"foreignAmount": null,
"foreignCurrencyCode": null,
"amountTHB": -369.0
}
],
"previousBalance": 14789.4,
"thisPeriodBalance": 15789.4,
"totalPayments": 678.0,
"totalInterestCharges": 0.0,
"reward": {
"rewardAccumulatedPoints": 1234,
"rewardPointsEarned": 56,
"bonusPointsEarned": 0,
"pointsAdjustedThisMonth": 0,
"pointsRedeemed": 0,
"pointsOutstanding": 1290
},
"paymentBarcodeNo": "1234567890123456789"
},
"process_ms": 6821
}
功能与能力
核心功能
-
文档处理
- 高精度文本提取和字段识别
- 泰语支持
- 快速处理时间(每份文档 5-10 秒)
- 多格式支持(JPEG、JPG、PNG、HEIC、HEIF、PDF)
- 多页文档处理
- 可选返回原始 OCR 文本和处理后的图像
- 符合 GDPR 和 PDPA 的处理
-
数据提取
- 灵活的 JSON 响应格式,提供详细的字段提取
支持的字段
| 字段 | 类型 | 描述 |
|---|---|---|
| statementType | String | 信用卡账单类型 |
| statementDate | String | 账单日期 |
| dueDate | String | 付款截止日期 |
| cardNumber | String | 信用卡号 |
| cardHolderName | String | 持卡人姓名 |
| bankName | String | 发卡行名称 |
| bankAddress | String | 发卡行地址 |
| bankTaxID | String | 发卡行税号 |
| bankPhone | String | 银行电话 |
| bankFax | String | 银行传真 |
| creditLimit | Number | 信用额度 |
| closingDate | String | 账单结算日期 |
| newBalancePayment | Number | 本次应还款额 |
| minimumPaymentDue | Number | 最低还款额 |
| interestRate | Number | 年利率(百分比) |
| paymentByDebitAccountNo | String | 关联借记账户号码 |
| transactions | Array | 交易详情数组 |
| payments_adjustment_others | Array | 付款和调整详情数组 |
| previousBalance | Number | 上期账单余额 |
| thisPeriodBalance | Number | 本期账单余额 |
| totalPayments | Number | 总付款额 |
| totalInterestCharges | Number | 总利息费用 |
| reward | Object | 奖励积分信息 |
| paymentBarcodeNo | String | 付款条形码编号 |
注意:所有货币值均四舍五入到小数点后两位。
API 参考
识别信用卡账单
有两种可用的端点用于处理信用卡账单:
1. 文件上传
POST https://api.iapp.co.th/ocr/v3/creditcard-statement/file
请求头
| 名称 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
| apikey | string | 是 | 您的 API 密钥 |
请求体 (multipart/form-data)
| 参数 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
| file | file | 是 | 账单图片 (JPEG, PNG) 或 PDF 文档 |
| return_image | boolean | 否 | 在响应中包含 base64 编码的图像(默认:false) |
| return_ocr | boolean | 否 | 在响应中包含原始 OCR 文本(默认:false) |
错误处理
| 状态 | 代码 | 描述 |
|---|---|---|
| 400 | BAD_REQUEST | 参数或文件格式无效 |
| 401 | UNAUTHORIZED | API 密钥无效或缺失 |
| 404 | NOT_FOUND | 端点无效 |
| 500 | INTERNAL_SERVER_ERROR | 处理失败 |
2. Base64 图像
POST https://api.iapp.co.th/ocr/v3/creditcard-statement/base64
请求头
| 名称 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
| apikey | string | 是 | 您的 API 密钥 |
请求体
您可以将 base64 数据作为 JSON 或表单数据发送:
JSON 格式:
{
"base64_string": "string", // Base64 编码的图像数据
"return_image": false, // 可选
"return_ocr": false // 可选
}
表单数据格式:
| 参数 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
| base64_string | string | 是 | Base64 编码的图像数据 |
| return_image | boolean | 否 | 在响应中包含 base64 编码的图像(默认:false) |
| return_ocr | boolean | 否 | 在响应中包含原始 OCR 文本(默认:false) |
响应格式
与文件上传端点相同
代码示例
Curl
curl -X POST https://api.iapp.co.th/v3/store/ocr/credit-card-statement \
-H "apikey: YOUR_API_KEY" \
-F "file=@/path/to/file.jpg"
Python (文件上传)
import requests
apiKey = 'YOUR_API_KEY'
filePath = '/path/to/creditcard-statement.jpg'
url = "https://api.iapp.co.th/ocr/v3/creditcard-statement/file"
headers = {'apikey': apiKey}
files = {'file': ('creditcard-statement.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'
filePath = '/path/to/creditcard-statement.jpg'
url = "https://api.iapp.co.th/ocr/v3/creditcard-statement/base64"
# Read image file and convert to base64
with open(filePath, '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 (文件上传)
const axios = require("axios")
const FormData = require("form-data")
const fs = require("fs")
const apiKey = "YOUR_API_KEY"
const filePath = "/path/to/creditcard-statement.jpg"
const url = "https://api.iapp.co.th/ocr/v3/creditcard-statement/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 filePath = "/path/to/creditcard-statement.jpg"
const url = "https://api.iapp.co.th/ocr/v3/creditcard-statement/base64"
// Read image file and convert to base64
const base64String = fs.readFileSync(filePath, { 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 (文件上传)
$url = 'https://api.iapp.co.th/ocr/v3/creditcard-statement/file';
$apiKey = 'YOUR_API_KEY';
$filePath = '/path/to/creditcard-statement.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)
$url = 'https://api.iapp.co.th/ocr/v3/creditcard-statement/base64';
$apiKey = 'YOUR_API_KEY';
$filePath = '/path/to/creditcard-statement.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 (文件上传)
import Foundation
let url = URL(string: "https://api.iapp.co.th/ocr/v3/creditcard-statement/file")!
let filePath = "/path/to/creditcard-statement.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=\"creditcard-statement.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/creditcard-statement/base64")!
let filePath = "/path/to/creditcard-statement.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 (文件上传)
import okhttp3.*
import java.io.File
val client = OkHttpClient()
val apiKey = "YOUR_API_KEY"
val filePath = "/path/to/creditcard-statement.jpg"
val url = "https://api.iapp.co.th/ocr/v3/creditcard-statement/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/creditcard-statement.jpg"
val url = "https://api.iapp.co.th/ocr/v3/creditcard-statement/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 (文件上传)
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/creditcard-statement/file";
String filePath = "/path/to/creditcard-statement.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/creditcard-statement/base64";
String filePath = "/path/to/creditcard-statement.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 (文件上传)
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
String url = 'https://api.iapp.co.th/ocr/v3/creditcard-statement/file';
String filePath = '/path/to/creditcard-statement.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;
String url = 'https://api.iapp.co.th/ocr/v3/creditcard-statement/base64';
String filePath = '/path/to/creditcard-statement.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}');
}
}