Back to OCR

API Documentation

Integrate Khmer OCR into your applications. Extract text, classify documents, and translate — all via a simple REST API.

Bearer token auth 60 RPM default API keys via admin

Quick Start

Get your API key from the admin, then make your first OCR request:

curl — OCR a document
curl -X POST https://ocr.angkor-ai.com/v1/ocr \
  -H "Authorization: Bearer sk_prod_your_api_key_here" \
  -F "image=@document.jpg" \
  -F "doc_type=government"
Response
{
  "success": true,
  "document_id": "a1b2c3d4-...",
  "title": "Royal Decree No. 123",
  "category": "government",
  "raw_text": "ព្រះរាជក្រឹត្យ...",
  "structured": { "reference_number": "123/2026", ... },
  "stats": { "chars": 2450, "lines": 45, "processing_ms": 11200, "engine": "angkor-ocr" },
  "credits": 100
}

Authentication

All API requests require a Bearer token. API keys are prefixed with sk_prod_ and issued by the admin.

Request header
Authorization: Bearer sk_prod_a1b2c3d4e5f6...

Important: API keys are shown only once at creation time. Store them securely. If lost, revoke and create a new one.

Endpoints

OCR
POST/v1/ocr50 credits

Extract text from a Khmer document image. Supports JPEG, PNG, WebP (max 20MB). Returns raw text, structured fields, and auto-classification.

Parameters (multipart/form-data)
image          File    Required  — The document image
doc_type       String  Optional  — government | cadastral | identity | handwritten (default: government)
thumbnail      String  Optional  — Base64 data URL for thumbnail storage
force_category String  Optional  — Override auto-classification
force_title    String  Optional  — Override auto-title
group_id       String  Optional  — Group ID for multi-page PDFs
page_number    Integer Optional  — Page number within group (default: 1)
Translation
POST/v1/translate20 credits

Translate extracted Khmer text to English, French, or Chinese.

Body (JSON)
{
  "text": "ព្រះរាជក្រឹត្យ...",
  "target": "en",           // en | fr | zh
  "document_id": "optional" // saves translation to document
}
Documents
GET/v1/documents

List your processed documents, grouped by multi-page PDF groups.

Query parameters
category  String  Optional — Filter by category
GET/v1/documents/:id

Get full document detail including raw text, structured data, and translations.

GET/v1/documents/group/:groupId

Get all pages of a multi-page document.

DELETE/v1/documents/:id

Delete a document and its thumbnail.

GET/v1/folders

Get category counts for document organization.

GET/v1/user

Get account info: email, credits, total usage.

Rate Limits

API key requests are rate-limited per minute. Limits are set per key and communicated via response headers.

Rate limit headers
X-RateLimit-Limit: 60        # Max requests per minute
X-RateLimit-Remaining: 42    # Requests left in current window
X-RateLimit-Reset: 1712345600 # Unix timestamp when window resets

Default: 60 requests per minute. Contact us for higher limits. Exceeding the limit returns 429 Too Many Requests.

Pricing

ActionCreditsPrice/page
OCR (per page)50$0.10
Translation (per page)20+$0.05
VolumePrice/page
1 - 999 pages$0.10
1,000 - 4,999$0.09
5,000 - 9,999$0.08
10,000+$0.07

Error Codes

CodeMeaning
400Bad request — missing or invalid parameters
401Unauthorized — invalid or missing API key
402Insufficient credits
403Forbidden — API key scope does not allow this action
404Resource not found
413File too large (max 20MB)
415Unsupported file type (use JPEG, PNG, or WebP)
429Rate limit exceeded — check Retry-After header
500Server error — retry the request

Get API Access

Contact us to get your API key and credits allocation.