API Reference
Complete REST API documentation for LeapOCR
API Reference
Complete REST API documentation for LeapOCR. The API uses standard HTTP methods and returns JSON responses.
Base URL: https://api.leapocr.com
All API requests require authentication via an API key in the X-API-Key header.
Authentication
Include your API key in the request header:
X-API-Key: your-api-key-herecurl -H "X-API-Key: your-api-key" \
https://api.leapocr.com/api/v1/jobsconst response = await fetch('https://api.leapocr.com/api/v1/jobs', {
headers: {
'X-API-Key': 'your-api-key'
}
});import httpx
async with httpx.AsyncClient() as client:
response = await client.get(
'https://api.leapocr.com/api/v1/jobs',
headers={'X-API-Key': 'your-api-key'}
)req, _ := http.NewRequest("GET", "https://api.leapocr.com/api/v1/jobs", nil)
req.Header.Set("X-API-Key", "your-api-key")
client := &http.Client{}
resp, _ := client.Do(req)OpenAPI Specification
For the complete OpenAPI 3.1 specification, see the interactive API reference below or download the spec:
Quick Reference
Endpoints
| Method | Endpoint | Description |
|---|---|---|
POST | /ocr/uploads/url | Submit document from URL |
POST | /ocr/uploads/direct | Submit document via direct upload |
POST | /ocr/uploads/{job_id}/complete | Complete multipart upload |
GET | /ocr/status/{job_id} | Get job status |
GET | /ocr/result/{job_id} | Get processing result |
DELETE | /ocr/jobs/{job_id} | Delete job and its data |
Processing Models
LeapOCR provides three AI models for document processing:
| Model | Display Name | Description | Credits/Page |
|---|---|---|---|
standard-v1 | Standard v1 | Baseline model, handles all cases | 1 |
english-pro-v1 | English Pro v1 | Premium quality, English documents only | 2 |
pro-v1 | Pro v1 | Highest quality, handles all cases | 3 |
Custom models may be available on your dashboard - use the model name directly as a string.
Output Formats
| Format | Description |
|---|---|
structured | Single JSON object with extracted fields |
markdown | Text per page in markdown format |
per_page_structured | JSON per page |
Submit Document from URL
Submit a document from a remote URL for OCR processing.
Request
POST /ocr/uploads/url
curl -X POST https://api.leapocr.com/ocr/uploads/url \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/document.pdf",
"output_type": "structured",
"model": "standard-v1",
"instruction": "Extract invoice details"
}'const response = await fetch('https://api.leapocr.com/ocr/uploads/url', {
method: 'POST',
headers: {
'X-API-Key': 'your-api-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://example.com/document.pdf',
output_type: 'structured',
model: 'standard-v1',
instruction: 'Extract invoice details'
})
});
const data = await response.json();import httpx
async with httpx.AsyncClient() as client:
response = await client.post(
'https://api.leapocr.com/ocr/uploads/url',
headers={'X-API-Key': 'your-api-key'},
json={
'url': 'https://example.com/document.pdf',
'output_type': 'structured',
'model': 'standard-v1',
'instruction': 'Extract invoice details'
}
)
data = response.json()body := map[string]interface{}{
"url": "https://example.com/document.pdf",
"output_type": "structured",
"model": "standard-v1",
"instruction": "Extract invoice details",
}
jsonBody, _ := json.Marshal(body)
req, _ := http.NewRequest("POST", "https://api.leapocr.com/ocr/uploads/url", bytes.NewBuffer(jsonBody))
req.Header.Set("X-API-Key", "your-api-key")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | URL to PDF document |
output_type | string | No | Output format: structured, markdown, per_page_structured |
model | string | No | Model to use (default: standard-v1) |
instruction | string | No | Processing instructions (cannot use with schema or template_slug) |
schema | object | No | JSON schema for extraction (cannot use with instruction) |
template_slug | string | No | Document template slug (cannot use with instruction or schema) |
Note: Only one of template_slug, schema, or instruction can be provided per request.
Response
{
"job_id": "job_abc123"
}Submit Document via Direct Upload
Upload a document file directly for OCR processing.
Request
POST /ocr/uploads/direct
curl -X POST https://api.leapocr.com/ocr/uploads/direct \
-H "X-API-Key: your-api-key" \
-F "file=@document.pdf" \
-F "output_type=structured" \
-F "model=standard-v1"const formData = new FormData();
formData.append('file', fileBuffer, 'document.pdf');
formData.append('output_type', 'structured');
formData.append('model', 'standard-v1');
const response = await fetch('https://api.leapocr.com/ocr/uploads/direct', {
method: 'POST',
headers: {
'X-API-Key': 'your-api-key'
},
body: formData
});import httpx
async with httpx.AsyncClient() as client:
with open('document.pdf', 'rb') as f:
response = await client.post(
'https://api.leapocr.com/ocr/uploads/direct',
headers={'X-API-Key': 'your-api-key'},
files={'file': f},
data={
'output_type': 'structured',
'model': 'standard-v1'
}
)file, _ := os.Open("document.pdf")
defer file.Close()
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, _ := writer.CreateFormFile("file", "document.pdf")
io.Copy(part, file)
writer.WriteField("output_type", "structured")
writer.WriteField("model", "standard-v1")
writer.Close()
req, _ := http.NewRequest("POST", "https://api.leapocr.com/ocr/uploads/direct", body)
req.Header.Set("X-API-Key", "your-api-key")
req.Header.Set("Content-Type", writer.FormDataContentType())Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
file | binary | Yes | PDF file to process |
output_type | string | No | Output format: structured, markdown, per_page_structured |
model | string | No | Model to use (default: standard-v1) |
instruction | string | No | Processing instructions (cannot use with schema or template_slug) |
schema | string | No | JSON schema as string (cannot use with instruction) |
template_slug | string | No | Document template slug (cannot use with instruction or schema) |
Response
{
"job_id": "job_abc123"
}Get Job Status
Check the status of a processing job.
Request
GET /ocr/status/{job_id}
Response
{
"job_id": "job_abc123",
"status": "completed",
"progress": 1.0
}Status Values
| Status | Description |
|---|---|
pending | Job queued, not started |
processing | Job in progress |
completed | Job finished successfully |
failed | Job failed |
Get Job Result
Retrieve the processing result for a completed job.
Request
GET /ocr/result/{job_id}
Response
{
"job_id": "job_abc123",
"status": "completed",
"credits_used": 3,
"processing_time_seconds": 45.2,
"pages": [
{
"page_number": 1,
"text": "Extracted text...",
"data": {
"invoice_number": "INV-2024-001",
"total": 1234.56
}
}
],
"data": {
"invoice_number": "INV-2024-001",
"total": 1234.56
}
}Delete Job
Delete a job and remove all its associated data. Jobs are automatically deleted after 7 days, but you can delete them immediately to remove sensitive data.
Request
DELETE /ocr/jobs/{job_id}
curl -X DELETE https://api.leapocr.com/ocr/jobs/job_abc123 \
-H "X-API-Key: your-api-key"const response = await fetch('https://api.leapocr.com/ocr/jobs/job_abc123', {
method: 'DELETE',
headers: {
'X-API-Key': 'your-api-key'
}
});import httpx
async with httpx.AsyncClient() as client:
response = await client.delete(
'https://api.leapocr.com/ocr/jobs/job_abc123',
headers={'X-API-Key': 'your-api-key'}
)req, _ := http.NewRequest("DELETE", "https://api.leapocr.com/ocr/jobs/job_abc123", nil)
req.Header.Set("X-API-Key", "your-api-key")
client := &http.Client{}
resp, _ := client.Do(req)Response
{
"message": "Job deleted successfully"
}Deleted jobs will have their content redacted and marked as deleted. The job record remains for audit purposes but all extracted data is permanently removed.
Error Handling
The API uses standard HTTP status codes:
| Status Code | Description |
|---|---|
200 | Success |
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Invalid API key |
404 | Not Found - Job not found |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error |
Error Response
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid format parameter",
"details": {
"field": "format",
"allowed_values": ["structured", "markdown", "per_page_structured"]
}
}
}Rate Limiting
API requests are rate limited based on your plan:
- Free: 10 requests/minute
- Pro: 100 requests/minute
- Enterprise: Custom limits
Rate limit information is included in response headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000OpenAPI Specification
Download or view the complete OpenAPI specification: