Khmer OCR — API Documentation
ឯកសារ API ពេញលេញសម្រាប់វេទិកា OCR ខ្មែរ — Complete API reference for the Khmer OCR Platform
Authentication | ការផ្ទៀងផ្ទាត់
All API endpoints require an API key. Include it in the request header:
X-API-Key: khocr_your_api_key_here
Or as a query parameter:
GET /api/v1/health?api_key=khocr_your_api_key_here
Contact chhinhsovath@gmail.com to request an API key for your organization.
Rate Limits
| Plan | Requests / min | Pages / month |
|---|---|---|
| Free | 10 | 100 |
| Standard | 50 | 5,000 |
| Enterprise | 200 | 50,000 |
Endpoints | ចំណុចភ្ជាប់
Convert a PDF document to text, Word, or JSON format.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
File | Required | PDF file (max 50 MB) |
output_format |
String | Optional | json, text, or docx (default: json) |
force_ocr |
Boolean | Optional | Force OCR even for native PDFs (default: false) |
priority |
String | Optional | high, normal, or low (default: normal) |
Example: cURL
curl -X POST https://khmer-ocr.openplp.com/api/v1/convert \
-H "X-API-Key: khocr_your_key" \
-F "file=@document.pdf" \
-F "output_format=json"
Example: Python
import requests
response = requests.post(
"https://khmer-ocr.openplp.com/api/v1/convert",
headers={"X-API-Key": "khocr_your_key"},
files={"file": open("document.pdf", "rb")},
data={"output_format": "json"},
)
result = response.json()
print(f"Job ID: {result['job_id']}")
Example: JavaScript
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('output_format', 'json');
const response = await fetch('/api/v1/convert', {
method: 'POST',
headers: { 'X-API-Key': 'khocr_your_key' },
body: formData,
});
const result = await response.json();
console.log('Job ID:', result.job_id);
Response
{
"job_id": "a1b2c3d4e5f6",
"status": "queued",
"message": "PDF submitted for processing",
"message_km": "ឯកសារ PDF បានដាក់សម្រាប់ដំណើរការ"
}
Check the status of a conversion job.
curl https://khmer-ocr.openplp.com/api/v1/jobs/a1b2c3d4e5f6 \
-H "X-API-Key: khocr_your_key"
{
"id": "a1b2c3d4e5f6",
"status": "PROCESSING",
"progress": 45.0,
"task_type": "convert",
"elapsed_seconds": 12.5
}
Get the result of a completed job.
Get current usage statistics for your organization.
API health check — no authentication required.
List available OCR and AI models.
Error Codes | កូដកំហុស
| Code | Description | ការពិពណ៌នា |
|---|---|---|
400 | Bad request (invalid file or parameters) | សំណើមិនត្រឹមត្រូវ |
401 | Invalid or missing API key | កូដ API មិនត្រឹមត្រូវ |
403 | Insufficient permissions | សិទ្ធិមិនគ្រប់គ្រាន់ |
404 | Resource not found | រកមិនឃើញ |
429 | Rate limit exceeded | ការស្នើសុំច្រើនពេក |
500 | Internal server error | កំហុសម៉ាស៊ីនមេ |
Support | ជំនួយ
For API access and support, contact: chhinhsovath@gmail.com
Platform: khmer-ocr.openplp.com