LeapOCRLeapOCR Docs

Get OCR Job Status

Retrieve current processing status and progress information for an OCR job

Get OCR Job Status

Retrieve current processing status and progress information for an OCR job. Shows completion status, progress percentage, and any error details.

Endpoint

GET /ocr/status/{job_id}

Parameters

ParameterTypeRequiredDescription
job_idstringYesOCR job ID

SDK Examples

# Get job status
curl -X GET https://api.leapocr.com/api/v1/ocr/status/job_abc123 \
  -H "X-API-Key: your-api-key"

# Response:
# {
#   "job_id": "job_abc123",
#   "status": "processing",
#   "progress": 0.45,
#   "total_pages": 10,
#   "processed_pages": 4
# }
import { LeapOCR } from "leapocr";

const client = new LeapOCR({
  apiKey: process.env.LEAPOCR_API_KEY,
});

// Get job status
const status = await client.ocr.getJobStatus(jobId);

console.log(`Status: ${status.status}`);
console.log(`Progress: ${status.progress?.toFixed(1)}%`);
console.log(`Processed pages: ${status.processed_pages}/${status.total_pages}`);

// Poll for completion
const pollInterval = 2000; // 2 seconds
while (status.status !== "completed") {
  await new Promise((resolve) => setTimeout(resolve, pollInterval));
  const status = await client.ocr.getJobStatus(jobId);
  console.log(`Progress: ${status.progress?.toFixed(1)}%`);
}
import asyncio
import os
from leapocr import LeapOCR

async def main():
    async with LeapOCR(os.getenv("LEAPOCR_API_KEY")) as client:
        # Get job status
        status = await client.ocr.get_job_status(job_id)

        print(f"Status: {status.status.value}")
        print(f"Progress: {status.progress:.1f}%")
        print(f"Processed pages: {status.processed_pages}/{status.total_pages}")

        # Poll for completion
        while status.status.value != "completed":
            await asyncio.sleep(2)
            status = await client.ocr.get_job_status(job_id)
            print(f"Progress: {status.progress:.1f}%")

asyncio.run(main())
package main

import (
    "context"
    "fmt"
    "log"
    "os"
    "time"
    "github.com/leapocr/leapocr-go"
)

func main() {
    client, err := ocr.New(os.Getenv("LEAPOCR_API_KEY"))
    if err != nil {
        log.Fatal(err)
    }

    ctx := context.Background()

    // Get job status
    status, err := client.GetJobStatus(ctx, jobID)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("Status: %s\n", status.Status)
    fmt.Printf("Progress: %.1f%%\n", status.Progress)
    fmt.Printf("Processed pages: %d/%d\n",
        status.ProcessedPages, status.TotalPages)

    // Poll for completion
    ticker := time.NewTicker(2 * time.Second)
    defer ticker.Stop()

    for status.Status != "completed" {
        <-ticker.C
        status, err = client.GetJobStatus(ctx, jobID)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Progress: %.1f%%\n", status.Progress)
    }
}

Response

{
  "job_id": "job_abc123",
  "status": "processing",
  "progress": 0.45,
  "total_pages": 10,
  "processed_pages": 4
}

Status Values

StatusDescription
pendingJob queued, not started
processingJob in progress
completedJob finished successfully
failedJob failed

Error Responses

Status CodeDescription
400Bad request - invalid job ID format
401Unauthorized - authentication required
403Forbidden - job belongs to different user
404Not found - job does not exist
500Internal server error

Tip: Use the SDK's waitUntilDone() method instead of manually polling for status. It handles polling and backoff automatically.

Using waitUntilDone

The SDKs provide a convenience method that polls for completion automatically:

# Poll for job completion (manual polling loop)
while true; do
  STATUS=$(curl -s -X GET https://api.leapocr.com/api/v1/ocr/status/job_abc123 \
    -H "X-API-Key: your-api-key" | jq -r '.status')

  echo "Status: $STATUS"

  if [ "$STATUS" = "completed" ] || [ "$STATUS" = "failed" ]; then
    break
  fi

  sleep 2
done

echo "Processing complete!"
const result = await client.ocr.waitUntilDone(jobId); console.log("Processing
complete!"); ```
</TabsContent>

<TabsContent value="python">
```python # Wait for job to complete (handles polling automatically) result =
await client.ocr.wait_until_done(job_id) print("Processing complete!") ```
</TabsContent>

<TabsContent value="go">
  ```go
  // Wait for job to complete (handles polling automatically)
  result, err := client.WaitUntilDone(ctx, jobID)
  if err != nil {
      log.Fatal(err)
  }
  fmt.Println("Processing complete!")

Next Steps