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:
npm install leapocrpip install leapocrgo 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",
instructions: "Extract invoice number, date, and total amount",
});
// 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);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,
instructions="Extract invoice number, date, and total amount"
)
)
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),
ocr.WithInstructions("Extract invoice number, date, and total amount"),
)
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": "job_abc123",
"status": "completed",
"credits_used": 3,
"processing_time_seconds": 12.5,
"pages": [
{
"page_number": 1,
"text": "Invoice content...",
"data": {
"invoice_number": "INV-2024-001",
"date": "2024-01-15",
"total": 1234.56
}
}
],
"data": {
"invoice_number": "INV-2024-001",
"date": "2024-01-15",
"total": 1234.56
}
}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.