API Tokens
| บัญชี | KBIZ User | API Token | สถานะ | Actions |
|---|---|---|---|---|
| กำลังโหลด... | ||||
API Usage Guide
ใช้ X-API-Token header ในทุก request. Base URL: https://bizplus-api.com
## ดูยอดเงิน
curl -H "X-API-Token: bpz_YOUR_TOKEN" \
https://bizplus-api.com/web/kbiz/balance
## ดูประวัติธุรกรรม (พร้อม filter)
curl -H "X-API-Token: bpz_YOUR_TOKEN" \
"https://bizplus-api.com/web/kbiz/transactions?from=2026-05-01&to=2026-05-22&limit=50&page=1"
## โอนเงิน
curl -X POST \
-H "X-API-Token: bpz_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"to_account":"xxx-x-xxxxx-x","to_bank":"KBANK","amount":500,"note":"ค่าสินค้า"}' \
https://bizplus-api.com/web/kbiz/transfer
## สั่ง Sync ทันที (ดึงข้อมูลล่าสุดจากธนาคาร)
curl -X POST -H "X-API-Token: bpz_YOUR_TOKEN" \
https://bizplus-api.com/web/kbiz/sync
## ดูสถานะ Sync
curl -H "X-API-Token: bpz_YOUR_TOKEN" \
https://bizplus-api.com/web/kbiz/sync/status
## หยุด Sync ทันที (Cancel)
curl -X POST -H "X-API-Token: bpz_YOUR_TOKEN" \
https://bizplus-api.com/web/kbiz/sync/cancel
## ดูสถานะ Session (เช็คว่า session ว่างหรือ busy ก่อนสั่งโอน)
curl -H "X-API-Token: bpz_YOUR_TOKEN" \
https://bizplus-api.com/web/kbiz/session/status
// Node.js / JavaScript (fetch)
const API_TOKEN = "bpz_YOUR_TOKEN";
const BASE_URL = "https://bizplus-api.com/web/kbiz";
// ดูยอดเงิน
const balance = await fetch(`${BASE_URL}/balance`, {
headers: { "X-API-Token": API_TOKEN }
}).then(r => r.json());
console.log(balance);
// { success: true, totalBalance: 125000.50, accounts: [...] }
// ดูประวัติธุรกรรม
const txns = await fetch(`${BASE_URL}/transactions?from=2026-05-01&limit=20`, {
headers: { "X-API-Token": API_TOKEN }
}).then(r => r.json());
console.log(txns.transactions);
// สั่ง Sync ทันที
const sync = await fetch(`${BASE_URL}/sync`, {
method: "POST",
headers: { "X-API-Token": API_TOKEN }
}).then(r => r.json());
console.log(sync);
// { success: true, status: "queued", message: "Sync request accepted" }
// หยุด Sync ทันที (Cancel)
const cancel = await fetch(`${BASE_URL}/sync/cancel`, {
method: "POST",
headers: { "X-API-Token": API_TOKEN }
}).then(r => r.json());
console.log(cancel);
// { success: true, message: "Sync cancelled successfully" }
// ดูสถานะ Session (เช็คว่า session ว่างหรือ busy ก่อนสั่งโอน)
const session = await fetch(`${BASE_URL}/session/status`, {
headers: { "X-API-Token": API_TOKEN }
}).then(r => r.json());
console.log(session);
// { exists: true, busy: true, currentAction: "poll-transactions", currentActionLabel: "กำลังดึง Statement อยู่", loggedIn: true, expired: false }
// โอนเงิน
const transfer = await fetch(`${BASE_URL}/transfer`, {
method: "POST",
headers: {
"X-API-Token": API_TOKEN,
"Content-Type": "application/json"
},
body: JSON.stringify({
to_account: "xxx-x-xxxxx-x",
to_bank: "KBANK",
amount: 500,
note: "ค่าสินค้า"
})
}).then(r => r.json());
import requests
API_TOKEN = "bpz_YOUR_TOKEN"
BASE_URL = "https://bizplus-api.com/web/kbiz"
HEADERS = {"X-API-Token": API_TOKEN}
# ดูยอดเงิน
r = requests.get(f"{BASE_URL}/balance", headers=HEADERS)
print(r.json())
# {'success': True, 'totalBalance': 125000.50, 'accounts': [...]}
# ดูประวัติธุรกรรม
r = requests.get(f"{BASE_URL}/transactions", headers=HEADERS, params={
"from": "2026-05-01",
"to": "2026-05-22",
"limit": 50
})
print(r.json()["transactions"])
# สั่ง Sync ทันที
r = requests.post(f"{BASE_URL}/sync", headers=HEADERS)
print(r.json())
# {'success': True, 'status': 'queued', 'message': 'Sync request accepted'}
# หยุด Sync ทันที (Cancel)
r = requests.post(f"{BASE_URL}/sync/cancel", headers=HEADERS)
print(r.json())
# {'success': True, 'message': 'Sync cancelled successfully'}
# ดูสถานะ Session (เช็คว่า session ว่างหรือ busy ก่อนสั่งโอน)
r = requests.get(f"{BASE_URL}/session/status", headers=HEADERS)
print(r.json())
# {'exists': True, 'busy': True, 'currentAction': 'poll-transactions', 'currentActionLabel': 'กำลังดึง Statement อยู่', 'loggedIn': True, 'expired': False}
# โอนเงิน
r = requests.post(f"{BASE_URL}/transfer", headers=HEADERS, json={
"to_account": "xxx-x-xxxxx-x",
"to_bank": "KBANK",
"amount": 500,
"note": "ค่าสินค้า"
})
print(r.json())
// GET /web/kbiz/balance
{
"success": true,
"totalBalance": 125000.50,
"accounts": [
{ "accountNo": "xxx-x-xxx89-0", "name": "ออมทรัพย์", "balance": 125000.50 }
],
"lastSyncAt": "2026-05-22T10:30:00"
}
// GET /web/kbiz/transactions?from=2026-05-01&limit=2
{
"success": true,
"total": 145,
"page": 1,
"pages": 73,
"transactions": [
{
"date": "2026-05-22 14:36:52",
"type": "FTOB",
"description": "รับโอนเงิน",
"debitCredit": "CR",
"from": null,
"to": "9132009152",
"beneficiaryName": "นาย สมชาย ใจดี",
"withdrawAmount": 0,
"depositAmount": 120.00,
"amount": 120.00,
"fee": 0,
"status": "สำเร็จ",
"ref": "001_20260522_069...",
"channel": "Internet/Mobile ต่างธนาคาร",
"bankName": "KBANK"
}
]
}
// POST /web/kbiz/sync
{
"success": true,
"status": "queued",
"message": "Sync request accepted"
}
// POST /web/kbiz/sync/cancel
{
"success": true,
"message": "Sync cancelled successfully"
}
// GET /web/kbiz/sync/status
{
"success": true,
"systemState": "sleeping", // sleeping | polling | logging_in | saving | queued
"isRunning": false,
"balance": 6853.65,
"nextSyncAt": "2026-05-22T16:15:00.000Z",
"nextSyncInMinutes": 45,
"lastSyncAt": "2026-05-22T15:30:00.000Z",
"lastSyncAgoMinutes": 1,
"backfillComplete": true,
"totalSyncedTx": 145,
"syncErrors": 0,
"lastError": null,
"job": null
}
// GET /web/kbiz/session/status (session busy)
{
"exists": true, // มี session ในระบบหรือไม่
"busy": true, // กำลังทำงานอยู่หรือเปล่า
"currentAction": "poll-transactions", // action ที่กำลังทำ
"currentActionLabel": "กำลังดึง Statement อยู่", // คำอธิบายภาษาไทย
"loggedIn": true, // login อยู่หรือยัง
"expired": false // session หมดอายุแล้วหรือยัง
}
// GET /web/kbiz/session/status (ไม่มี session)
{
"exists": false,
"busy": false,
"currentAction": null
}
// POST /web/kbiz/transfer (session ว่าง)
{
"success": true,
"status": "accepted",
"jobId": "tf_api_1_1716800000000",
"sessionBusy": false,
"message": "กำลังดำเนินการโอนเงิน — poll สถานะที่ GET /web/kbiz/transfer/status?jobId=..."
}
// POST /web/kbiz/transfer (session busy — จะรอคิวอัตโนมัติ)
{
"success": true,
"status": "accepted",
"jobId": "tf_api_1_1716800000000",
"sessionBusy": true,
"sessionAction": "poll-transactions",
"sessionActionLabel": "กำลังดึง Statement อยู่",
"warning": "⚠️ Session กำลังทำงาน (กำลังดึง Statement อยู่) — คำสั่งโอนจะรอคิว (สูงสุด 60 วินาที)",
"message": "กำลังดำเนินการโอนเงิน — poll สถานะที่ GET /web/kbiz/transfer/status?jobId=..."
}
// Webhook Payload (ส่งอัตโนมัติเมื่อมีธุรกรรมใหม่)
{
"event": "new_transactions",
"account_id": 1,
"member_hid": "01-01-01",
"count": 2,
"transactions": [
{
"date": "2026-05-22 14:36:52",
"type": "FTOB",
"description": "รับโอนเงิน",
"debit_credit": "CR",
"withdraw_amount": 0,
"deposit_amount": 120.00,
"amount": 120.00,
"channel": "Internet/Mobile ต่างธนาคาร",
"ref_no": "001_20260522_069...",
"status": "สำเร็จ"
}
],
"systemState": "sleeping",
"balance": 6853.65,
"nextSyncAt": "2026-05-22T16:15:00.000Z",
"nextSyncInMinutes": 45,
"timestamp": "2026-05-22T15:30:00.000Z"
}
// Error Response (ตัวอย่าง)
{
"success": false,
"error": "Invalid API Token"
}
หมายเหตุ — การทำงานของระบบ Sync
| Sync อัตโนมัติ | ระบบตรวจสอบธุรกรรมใหม่จาก KBIZ อัตโนมัติทุก 30-60 นาที (สุ่มเวลาให้สมจริงเหมือนคนใช้งาน) |
| Poll Mode | เมื่อถึงเวลา sync หรือผู้ใช้กด Sync Now — ระบบจะ login KBIZ แล้วกด "ค้นหา" ทุก 30-50 วินาที ต่อเนื่อง 5-10 นาที เพื่อเก็บรายการ real-time และรักษา session ให้มีชีวิต |
| Backfill Mode | ครั้งแรกที่ลงทะเบียน — ระบบจะดึงข้อมูลย้อนหลังตั้งแต่ วันที่ 1 ของเดือน ถึง เมื่อวาน ให้อัตโนมัติ |
| Balance | ดึงยอดเงินคงเหลือจาก API ธนาคารโดยตรง อัพเดตทุกรอบ sync (ทุก 3 poll จะ refresh balance ใหม่) |
| Notification | เมื่อพบธุรกรรมใหม่ ระบบจะส่งแจ้งเตือนอัตโนมัติผ่าน Webhook / Line Notify / Telegram ตาม config ที่ตั้งไว้ |
| Sync ซ้ำ | ถ้าสั่ง Sync ขณะที่กำลัง Sync/Backfill อยู่ → ระบบจะ ข้ามคำสั่งใหม่ ไม่ทำซ้ำ (ป้องกัน browser ชนกัน) |
| โอนขณะ Sync | คำสั่งโอนเงินจะ รอ สูงสุด 60 วินาทีให้ Sync เสร็จก่อน แล้วค่อยทำ — ถ้ารอไม่ไหวจะแจ้ง error SESSION_BUSY |
| หยุด Sync | เรียก POST /web/kbiz/sync/cancel เพื่อหยุด Sync ที่กำลังทำงานทันที — ระบบจะปิด browser session และหยุด poll loop ภายใน 5 วินาที |
| ดู Session Status | เรียก GET /web/kbiz/session/status เพื่อเช็คว่า session ว่างหรือ busy ก่อนสั่งโอน — ใช้ตรวจสอบว่าตอนนี้ระบบกำลังทำ Sync/Backfill/โอนเงินอยู่หรือไม่ ค่า currentAction จะบอกว่ากำลังทำอะไร |
| การเก็บข้อมูล | ข้อมูลธุรกรรมเก็บใน Database 1 ปี — หลังจากนั้นลบอัตโนมัติ |
ค่า systemState
sleepingรอรอบถัดไป (ไม่ทำงาน)pollingกำลังดึงข้อมูลธุรกรรมlogging_inกำลัง login KBIZsavingกำลังบันทึก DBqueuedอยู่ในคิวรอดำเนินการfetching_balanceกำลังดึงยอดเงิน
Sync Now: เรียก
POST /web/kbiz/sync เพื่อบังคับดึงข้อมูลทันที ไม่ต้องรอรอบ — จากนั้นเช็คสถานะผ่าน GET /web/kbiz/sync/status ดู nextSyncInMinutes เพื่อรู้ว่าครั้งถัดไปจะ sync เมื่อไหร่