API Documentation
Integrate Khmer OCR into your applications. Extract text, classify documents, and translate — all via a simple REST API.
Quick Start
Get your API key from the admin, then make your first OCR request:
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"{
"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.
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
/v1/ocr50 creditsExtract text from a Khmer document image. Supports JPEG, PNG, WebP (max 20MB). Returns raw text, structured fields, and auto-classification.
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)/v1/translate20 creditsTranslate extracted Khmer text to English, French, or Chinese.
{
"text": "ព្រះរាជក្រឹត្យ...",
"target": "en", // en | fr | zh
"document_id": "optional" // saves translation to document
}/v1/documentsList your processed documents, grouped by multi-page PDF groups.
category String Optional — Filter by category/v1/documents/:idGet full document detail including raw text, structured data, and translations.
/v1/documents/group/:groupIdGet all pages of a multi-page document.
/v1/documents/:idDelete a document and its thumbnail.
/v1/foldersGet category counts for document organization.
/v1/userGet 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.
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 resetsDefault: 60 requests per minute. Contact us for higher limits. Exceeding the limit returns 429 Too Many Requests.
Pricing
| Action | Credits | Price/page |
|---|---|---|
| OCR (per page) | 50 | $0.10 |
| Translation (per page) | 20 | +$0.05 |
| Volume | Price/page |
|---|---|
| 1 - 999 pages | $0.10 |
| 1,000 - 4,999 | $0.09 |
| 5,000 - 9,999 | $0.08 |
| 10,000+ | $0.07 |
Error Codes
| Code | Meaning |
|---|---|
| 400 | Bad request — missing or invalid parameters |
| 401 | Unauthorized — invalid or missing API key |
| 402 | Insufficient credits |
| 403 | Forbidden — API key scope does not allow this action |
| 404 | Resource not found |
| 413 | File too large (max 20MB) |
| 415 | Unsupported file type (use JPEG, PNG, or WebP) |
| 429 | Rate limit exceeded — check Retry-After header |
| 500 | Server error — retry the request |