คู่มือOCR APIThai OCR APIAPI IntegrationDeveloper
Thai OCR API คู่มือครบ: เริ่มต้น Integration ใน 5 นาที
คู่มือการใช้ Thai OCR API อย่างละเอียด ตั้งแต่การขอ API Key จนถึง integration กับ Node.js, Python, PHP พร้อมตัวอย่าง code จริง
A
AksonOCR Team
Jan 25, 2026 · 5 min read

AksonOCR Thai OCR API คืออะไร?
AksonOCR API คือ REST API สำหรับนักพัฒนาที่ต้องการเพิ่มความสามารถ OCR ภาษาไทยเข้าในแอปพลิเคชัน ระบบ หรือ workflow ของตัวเอง โดยไม่ต้องพัฒนา AI Engine เอง
ข้อดีของการใช้ OCR API
- ไม่ต้องดูแล Infrastructure — API พร้อมใช้งานตลอด 24/7
- Scale ได้ทันที — รองรับตั้งแต่ 1 ถึง 1,000,000 ไฟล์ต่อเดือน
- อัปเดตโมเดลอัตโนมัติ — ได้ใช้ AI ล่าสุดโดยไม่ต้อง retrain
- ค่าใช้จ่ายตาม usage — จ่ายตามที่ใช้จริง
เริ่มต้นใช้งาน Thai OCR API
ขั้นตอนที่ 1: ลงทะเบียนและรับ API Key
- ไปที่ aksonocr.com
- คลิก "เริ่มต้นใช้งานฟรี"
- สร้างบัญชีด้วย email
- ไปที่ Dashboard → API Keys → สร้าง Key ใหม่
ขั้นตอนที่ 2: ทดสอบด้วย cURL
# อัปโหลดไฟล์และรับข้อความ OCR
curl -X POST https://api.aksonocr.com/v2/upload \
-H "Authorization: Bearer sk_live_YOUR_API_KEY" \
-F "[email protected]" \
-F "model=aksonocr-1.0"
ตัวอย่างการตอบกลับ (Response)
{
"pages": [
{
"index": 0,
"markdown": "# ใบสั่งซื้อ\n\nวันที่: 25 มกราคม 2567..."
}
],
"usage": {
"pages": 1
}
}
Integration Guide: ภาษาต่างๆ
Node.js / TypeScript
import FormData from 'form-data';
import fs from 'fs';
import fetch from 'node-fetch';
async function extractTextFromImage(filePath: string): Promise<string> {
const form = new FormData();
form.append('file', fs.createReadStream(filePath));
form.append('model', 'aksonocr-1.0');
const res = await fetch('https://api.aksonocr.com/v2/upload', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.AKSONOCR_API_KEY}`,
...form.getHeaders(),
},
body: form,
});
const data = await res.json() as { pages: { markdown: string }[] };
return data.pages.map(p => p.markdown).join('\n\n');
}
Python
import os
import requests
def ocr_extract(file_path: str) -> str:
url = "https://api.aksonocr.com/v2/upload"
headers = {"Authorization": f"Bearer {os.environ['AKSONOCR_API_KEY']}"}
with open(file_path, "rb") as f:
files = {"file": f}
data = {"model": "aksonocr-1.0"}
response = requests.post(url, headers=headers, files=files, data=data)
response.raise_for_status()
result = response.json()
return "\n\n".join(page["markdown"] for page in result["pages"])
# ตัวอย่างการใช้งาน
text = ocr_extract("invoice_thai.pdf")
print(text)
PHP
<?php
function aksonOcrExtract(string $filePath): string {
$curl = curl_init();
$apiKey = getenv('AKSONOCR_API_KEY');
$postData = [
'file' => new CURLFile($filePath),
'model' => 'aksonocr-1.0',
];
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.aksonocr.com/v2/upload',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postData,
CURLOPT_HTTPHEADER => ["Authorization: Bearer {$apiKey}"],
]);
$response = curl_exec($curl);
curl_close($curl);
$data = json_decode($response, true);
return implode("\n\n", array_column($data['pages'], 'markdown'));
}
API Endpoints ที่สำคัญ
POST /v2/upload
อัปโหลดไฟล์และรับผลลัพธ์ OCR ในรูปแบบ Markdown
| Parameter | Type | Required | Description |
|---|---|---|---|
file | File | ✅ | ไฟล์ภาพ PNG, JPG, TIFF หรือ PDF |
model | string | ✅ | aksonocr-1.0 (default) |
Headers
| Header | Value |
|---|---|
Authorization | Bearer YOUR_API_KEY |
Content-Type | multipart/form-data |
Error Handling
try {
const result = await ocrExtract(filePath);
} catch (error) {
if (error.status === 401) {
console.error('API Key ไม่ถูกต้อง');
} else if (error.status === 429) {
console.error('เกิน Rate Limit — รอแล้วลองใหม่');
} else if (error.status === 402) {
console.error('Credits หมด — เติม Credits ก่อน');
}
}
เริ่ม Integration วันนี้
รับ API Key ฟรี 20 Credits ทดสอบได้เลย ไม่ต้องใส่บัตรเครดิต
👉 สมัครฟรี: https://aksonocr.com
👉 Full API Docs: https://docs.aksonocr.com
Share this article