API Docs
API Documentation
เชื่อมต่อ ScanlyIQ เข้ากับระบบของคุณผ่าน REST API
Authentication
สร้าง API Key ได้ที่หน้า Settings → API Keys (ต้อง login ก่อน)
ส่ง API Key ผ่าน header ทุก request:
Authorization: Bearer b2t_live_xxxxxxxxxxxxxxxx...
Base URL: https://www.scanlyiq.com/api
Endpoints
POST
/api/upload/slipอัปโหลดรูปสลิปหรือใบเสร็จก่อนส่งสแกน OCR
Headers
Authorization: Bearer {api_key}
Content-Type: multipart/form-dataRequest
files[] (JPEG/PNG/WebP, max 50MB each, max 50 files)
Response
{
"uploads": [
{ "id": "upload_abc123", "fileName": "slip1.jpg", "fileSize": 245120 }
]
}POST
/api/jobs/slip-ocrสร้าง OCR job จากไฟล์ที่อัปโหลดแล้ว ระบบจะหักเครดิตอัตโนมัติ
Headers
Authorization: Bearer {api_key}
Content-Type: application/jsonRequest
{
"uploadIds": ["upload_abc123", "upload_def456"],
"modelId": "model_id",
"projectId": "project_id", // optional
"documentType": "slip" // optional: "slip" | "invoice"
}Response
{
"jobId": "job_xyz789",
"status": "PENDING",
"itemCount": 2,
"creditsCharged": 4
}GET
/api/jobs/slip-ocr/{jobId}ดึงสถานะและผลลัพธ์ของ OCR job (polling จนกว่า status จะเป็น COMPLETED)
Headers
Authorization: Bearer {api_key}Response
{
"id": "job_xyz789",
"status": "COMPLETED",
"items": [{
"status": "COMPLETED",
"result": {
"bank": "กสิกรไทย",
"amount": 1500.00,
"date": "2026-03-18",
"fromAccount": "xxx-x-x1234-x",
"toAccount": "xxx-x-x5678-x"
}
}]
}GET
/api/creditsดูยอดเครดิตคงเหลือและยอดใช้ไปทั้งหมด
Headers
Authorization: Bearer {api_key}Response
{
"balance": 150,
"totalUsed": 350,
"packages": [...]
}POST
/api/credits/estimateคำนวณเครดิตที่ต้องใช้ก่อนสร้าง job
Headers
Authorization: Bearer {api_key}
Content-Type: application/jsonRequest
{
"type": "SLIP_OCR",
"modelId": "model_id",
"itemCount": 5
}Response
{
"estimatedCredits": 10,
"currentBalance": 150,
"sufficient": true,
"creditsPerUnit": 2,
"modelName": "Gemini 2.5 Flash"
}GET
/api/modelsดูรายชื่อ AI Models ที่ใช้งานได้ พร้อมราคาต่อหน่วย
Headers
Authorization: Bearer {api_key}Response
{
"models": [{
"id": "clx...",
"name": "Gemini 2.5 Flash",
"type": "VISION",
"creditsPerUnit": 2
}]
}Rate Limits
| Endpoint | Limit | Window |
|---|---|---|
| /api/auth/* | 10 req | 60 วินาที |
| /api/upload/* | 20 req | 60 วินาที |
| /api/webhooks/* | 100 req | 60 วินาที |
| /api/* (อื่นๆ) | 60 req | 60 วินาที |
Error Codes
| Code | Status | คำอธิบาย |
|---|---|---|
| 400 | Bad Request | ข้อมูลไม่ถูกต้อง ตรวจสอบ request body |
| 401 | Unauthorized | API Key ไม่ถูกต้องหรือหมดอายุ |
| 402 | Insufficient Credits | เครดิตไม่เพียงพอ กรุณาเติมเครดิต |
| 403 | Forbidden | ไม่มีสิทธิ์เข้าถึง resource นี้ |
| 404 | Not Found | ไม่พบ resource ที่ร้องขอ |
| 429 | Rate Limited | คำขอมากเกินไป กรุณารอสักครู่ |
พร้อมเริ่มใช้งาน API แล้วหรือยัง?
สร้าง API Key แล้วเริ่มเชื่อมต่อระบบของคุณได้ทันที