Key Extraction v3 · ตัวอย่าง

ใบสั่งซื้อ

ใบสั่งซื้อ — เลขที่ PO ผู้ขาย วันส่งของ และตารางรายการสินค้า พร้อม bbox ต่อเซลล์

Endpoint
POST /api/v3/key-extract/jobs
ไฟล์
purchase-order.pdf
ฟิลด์
9 ฟิลด์ · required 1
ตาราง
line_items[]
หลักฐาน
bbox ต่อฟิลด์ (ค่าเริ่มต้น)
ผลลัพธ์
ตัวอย่างประกอบ

data_schema

json
{
"type": "object",
"additionalProperties": false,
"properties": {
"po_number": {
"type": "string",
"description": "เลขที่ใบสั่งซื้อ"
},
"po_date": {
"type": "string",
"description": "วันที่ออกใบสั่งซื้อ"
},
"vendor": {
"type": "string",
"description": "ชื่อผู้ขาย"
},
"delivery_date": {
"type": "string",
"description": "วันที่ต้องการให้ส่งของ"
},
"total": {
"type": "number",
"description": "ยอดรวมใบสั่งซื้อ"
},
"line_items": {
"type": "array",
"description": "รายการสินค้า",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"sku": {
"type": "string",
"description": "รหัสสินค้า"
},
"name": {
"type": "string"
},
"quantity": {
"type": "number"
},
"unit_price": {
"type": "number"
}
}
}
}
},
"required": [
"po_number"
]
}

Request

อัปโหลดไฟล์ สร้างงานด้วย schema ด้านบน poll จนจบ แล้วดึงผล

import json, time, requests
API = "https://backend.aksonocr.com/api/v3/key-extract"
headers = {"X-API-Key": "<YOUR_API_KEY>"}
schema = json.load(open("schema.json", encoding="utf-8"))
with open("purchase-order.pdf", "rb") as document:
file_id = requests.post(f"{API}/files", headers=headers, files={"files": document}).json()["files"][0]["id"]
job_id = requests.post(
f"{API}/jobs",
headers={**headers, "Idempotency-Key": "po-001"},
json={
"inputs": [{"file_id": file_id}],
"data_schema": schema,
},
).json()["id"]
while requests.get(f"{API}/jobs/{job_id}", headers=headers).json()["status"] not in {
"completed", "failed", "cancelled", "expired"
}:
time.sleep(2)
result = requests.get(f"{API}/jobs/{job_id}/result", headers=headers).json()
print(result["data"])
print(result["validation"])

ผลลัพธ์

ตัวอย่างประกอบ

ค่าด้านล่างแสดงรูปแบบผลลัพธ์ ไม่ได้มาจากเอกสารจริง
json
{
"needs_review": true,
"data": {
"po_number": "PO-2026-0381",
"po_date": "12 ต.ค. 2569",
"vendor": "บริษัท ซัพพลาย ตัวอย่าง จำกัด",
"delivery_date": "20 ต.ค. 2569",
"total": 12840,
"line_items": [
{
"sku": "A4-80G",
"name": "กระดาษ A4 80 แกรม",
"quantity": 20,
"unit_price": 120
},
{
"sku": "TN-245",
"name": "ผงหมึก TN-245",
"quantity": 4,
"unit_price": 2610
}
]
},
"field_metadata": {
"/po_number": {
"status": "verified",
"confidence": 0.99,
"regions": [
{
"page": 1,
"bbox": [
0.701,
0.081,
0.893,
0.107
],
"text": "PO-2026-0381"
}
]
},
"/delivery_date": {
"status": "needs_review",
"confidence": 0.71,
"regions": [
{
"page": 1,
"bbox": [
0.702,
0.149,
0.861,
0.172
],
"text": "20 ต.ค. 2569"
}
]
}
},
"validation": {
"missing_required": [],
"below_threshold": [
"/delivery_date"
]
}
}

delivery_date มี confidence ต่ำกว่า review_threshold (ค่าเริ่มต้น 0.8) จึงอยู่ใน validation.below_threshold และ needs_review เป็น true ค่าใน data ไม่ถูกแก้ ใช้ธงนี้ส่งเข้าคิวตรวจทาน

ความหมายของ status, confidence และ bbox อยู่ที่ การดึงผลลัพธ์