LeapOCRLeapOCR Docs

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-here
curl -H "X-API-Key: your-api-key" \
  https://api.leapocr.com/api/v1/jobs
const 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

MethodEndpointDescription
POST/ocr/uploads/urlSubmit document from URL
POST/ocr/uploads/directSubmit document via direct upload
POST/ocr/uploads/{job_id}/completeComplete 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:

ModelDisplay NameDescriptionCredits/Page
standard-v1Standard v1Baseline model, handles all cases1
english-pro-v1English Pro v1Premium quality, English documents only2
pro-v1Pro v1Highest quality, handles all cases3

Custom models may be available on your dashboard - use the model name directly as a string.

Output Formats

FormatDescription
structuredSingle JSON object with extracted fields
markdownText per page in markdown format
per_page_structuredJSON 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

ParameterTypeRequiredDescription
urlstringYesURL to PDF document
output_typestringNoOutput format: structured, markdown, per_page_structured
modelstringNoModel to use (default: standard-v1)
instructionstringNoProcessing instructions (cannot use with schema or template_slug)
schemaobjectNoJSON schema for extraction (cannot use with instruction)
template_slugstringNoDocument 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

ParameterTypeRequiredDescription
filebinaryYesPDF file to process
output_typestringNoOutput format: structured, markdown, per_page_structured
modelstringNoModel to use (default: standard-v1)
instructionstringNoProcessing instructions (cannot use with schema or template_slug)
schemastringNoJSON schema as string (cannot use with instruction)
template_slugstringNoDocument 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

StatusDescription
pendingJob queued, not started
processingJob in progress
completedJob finished successfully
failedJob 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 CodeDescription
200Success
400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
404Not Found - Job not found
429Too Many Requests - Rate limit exceeded
500Internal 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: 1640000000

OpenAPI Specification

Download or view the complete OpenAPI specification: