Getting Started
Quick start guide to processing your first document with LeapOCR
Getting Started
Get up and running with LeapOCR in under 5 minutes. This guide will walk you through processing your first document.
What you'll need: - A LeapOCR API key (sign up here) - A PDF or image document to process - Basic knowledge of your preferred programming language
Quick Start
Get Your API Key
- Sign up at leapocr.com/signup
- Navigate to your dashboard
- Copy your API key
- Store it securely (use environment variables)
export LEAPOCR_API_KEY="your-api-key-here"Choose Your SDK
Select the SDK for your programming language:
- JavaScript/TypeScript - For Node.js and browsers
- Python - For Python applications
- Go - For Go applications
- REST API - For direct HTTP access
Install the SDK
Install the appropriate package for your language:
bash npm install leapocr bash pip install leapocr go get github.com/leapocr/leapocr-goProcess Your First Document
Here's a simple example in each language:
import { LeapOCR } from "leapocr";
const client = new LeapOCR({
apiKey: process.env.LEAPOCR_API_KEY,
});
// Process a document
const job = await client.ocr.processURL("https://example.com/invoice.pdf", {
format: "structured",
});
// Wait for completion
const result = await client.ocr.waitUntilDone(job.jobId);
console.log("Extracted data:", result.data);
// Delete the job
await client.ocr.deleteJob(job.jobId);# Submit document for processing
curl -X POST https://api.leapocr.com/api/v1/ocr/uploads/url \
-H "X-API-Key: $LEAPOCR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/invoice.pdf",
"output_type": "structured"
}'
# Returns: {"job_id": "019aac22-ea27-7b57-a104-5cb5ae64e3cb"}
# Check job status
curl https://api.leapocr.com/api/v1/ocr/jobs/019aac22-ea27-7b57-a104-5cb5ae64e3cb/status \
-H "X-API-Key: $LEAPOCR_API_KEY"
# Get result when status is "completed"
curl https://api.leapocr.com/api/v1/ocr/jobs/019aac22-ea27-7b57-a104-5cb5ae64e3cb/result \
-H "X-API-Key: $LEAPOCR_API_KEY"
# Delete the job
curl -X DELETE https://api.leapocr.com/api/v1/ocr/jobs/019aac22-ea27-7b57-a104-5cb5ae64e3cb \
-H "X-API-Key: $LEAPOCR_API_KEY"import asyncio
from leapocr import LeapOCR, ProcessOptions, Format
async def main():
async with LeapOCR(os.getenv("LEAPOCR_API_KEY")) as client:
result = await client.ocr.process_and_wait(
"https://example.com/invoice.pdf",
options=ProcessOptions(
format=Format.STRUCTURED,
)
)
print("Extracted data:", result.data)
# Delete the job
await client.ocr.delete_job(result.job_id)
asyncio.run(main())package main
import (
"context"
"fmt"
"log"
"os"
"github.com/leapocr/leapocr-go"
)
func main() {
client, _ := ocr.New(os.Getenv("LEAPOCR_API_KEY"))
ctx := context.Background()
job, _ := client.ProcessURL(ctx,
"https://example.com/invoice.pdf",
ocr.WithFormat(ocr.FormatStructured),
)
result, _ := client.WaitUntilDone(ctx, job.ID)
fmt.Printf("Extracted data: %+v\n", result.Data)
// Delete the job
client.DeleteJob(ctx, job.ID)
}Understanding the Response
When processing completes, you'll receive a result with this structure:
{
"job_id": "019aac22-ea27-7b57-a104-5cb5ae64e3cb",
"status": "completed",
"result_format": "structured",
"completed_at": "2025-11-22T20:46:19.155732+05:30",
"pages": [
{
"id": "019aac23-31e4-78fd-8911-427e43298e91",
"page_number": 1,
"result": {
"buyer_info": {
"location": "Niherne",
"name": "Vve LABRUNE"
},
"invoice_details": {
"date": "Avril 1920",
"invoice_number": "1560",
"place_of_issue": "Châteauroux"
},
"line_items": [
{
"description": "1/2 tomate",
"quantity": 24,
"total_price": 12,
"unit_price": 0.5
},
{
"description": "4/4 tomate",
"quantity": 24,
"total_price": 24,
"unit_price": 1
},
{
"description": "Lessive k",
"quantity": 10,
"total_price": 7,
"unit_price": 0.7
},
{
"description": "Boite pains epice",
"quantity": 1,
"total_price": 3.4,
"unit_price": null
},
{
"description": "Tapioca",
"quantity": 3,
"total_price": 9.75,
"unit_price": 3.25
},
{
"description": "Paquets de bougies 6 T",
"quantity": 10,
"total_price": 34,
"unit_price": 3.4
},
{
"description": "Sortie",
"quantity": null,
"total_price": 0.1,
"unit_price": null
}
],
"seller_info": {
"address": "66-68, Place Voltaire - CHATEAUROUX",
"business_type": "EPICERIE EN GROS",
"name": "MAISON JEAN ÉLION",
"phone": "89"
},
"total_amount": 90.25
}
}
],
"credits_used": 5,
"total_pages": 1,
"processed_pages": 1,
"file_name": "test-inoivce-french.pdf",
"model": "pro-v1",
"pagination": {
"page": 1,
"limit": 100,
"total": 1,
"total_pages": 1
}
}Next Steps
Now that you've processed your first document, explore these topics:
Core Concepts
- Processing Models - Choose the right AI model
- Output Formats - Understand different output types
- Custom Schemas - Define structured extraction
Common Use Cases
Advanced Features
- Error Handling - Handle failures gracefully
- Custom Models - Use specialized models
Common Issues
Authentication Error?
Make sure your API key is correctly set and valid. Check that you're using the environment variable or passing it correctly to the SDK.
Job Timing Out?
Large documents may take longer to process. The waitUntilDone method has a default timeout. For very large documents, consider polling the status manually with a longer timeout.
Ready to dive deeper? Check out the SDK documentation for your language or explore use cases for inspiration.