Home / Developers
Developer guide
A REST API with JSON responses. Most teams integrate in an afternoon.
1. Get a key
You get two kinds of key. lo_test_... keys are free, work on every endpoint and are never billed, so use them while you build. lo_live_... keys are for production. Keep keys on your server, never in a mobile app or web page.Request a test key.
2. Send a document
curl https://api.lendocr.com/v1/documents:extract \
-H "Authorization: Bearer lo_test_..." \
-F file=@pan.jpgPython
import requests
r = requests.post(
"https://api.lendocr.com/v1/documents:extract",
headers={"Authorization": "Bearer lo_test_..."},
files={"file": open("statement.pdf", "rb")},
data={"password": "optional-pdf-password"},
timeout=60,
)
r.raise_for_status()
doc = r.json()
if doc["needs_review"]:
print("Send to a reviewer:", doc["warnings"])Node.js
const form = new FormData();
form.append("file", new Blob([await fs.promises.readFile("pan.jpg")]), "pan.jpg");
const res = await fetch("https://api.lendocr.com/v1/documents:extract", {
method: "POST",
headers: { Authorization: "Bearer lo_test_..." },
body: form,
});
const doc = await res.json();
console.log(doc.document_type, doc.fields);Form fields
| Field | Default | Meaning |
|---|---|---|
file | required | JPEG, PNG, WebP, TIFF, BMP or PDF; up to 10 MB and 50 pages |
document_type | auto | Name the type, or let LendOCR detect it |
engine | auto | fast, accurate, or auto (fast first, careful second read when needed) |
password | none | For password-protected PDFs |
Endpoints
| Method | Path | Purpose |
|---|---|---|
POST | /v1/documents:extract | Fields, checks and needs_review for one document |
POST | /v1/documents:batch | Up to 10 documents in one call, results per file |
POST | /v1/documents:read | All the text in any document, page by page |
POST | /v1/jobs | Queue 1-20 documents for background processing (202) |
GET | /v1/jobs/{job_id} | Job status, and the full result when done |
DELETE | /v1/jobs/{job_id} | Cancel a queued job or erase a result now |
POST | /v1/validate | Check a single PAN, Aadhaar, GSTIN, IFSC, DL, passport and more |
GET | /v1/usage | Pages your organisation used this month |
GET | /v1/document-types | Supported documents |
Responses and errors
Successful responses carry fields (value and confidence), checks,needs_review and warnings. Errors use standard HTTP codes with a JSON body (application/problem+json) and a request_id for support.
| Status | When |
|---|---|
401 | Missing, wrong, revoked or expired API key |
403 | The key does not have this scope |
413 / 415 | File larger than 10 MB / not a readable image or PDF |
422 | Invalid field, wrong PDF password, or unknown document type |
429 | Rate limit or monthly quota reached; see Retry-After |
503 | Busy; see Retry-After and try again |
Every response includes X-RateLimit-Limit, X-RateLimit-Remaining and X-Request-ID.
Background jobs and webhooks
For large statements and bulk uploads, queue the files and get notified. Sending the sameIdempotency-Key again returns the same jobs, so retries never create duplicates.
curl https://api.lendocr.com/v1/jobs \
-H "Authorization: Bearer lo_live_..." \
-H "Idempotency-Key: loan-app-1042" \
-F files=@statement.pdf -F files=@pan.jpg \
-F webhook_url=https://your-server.example.com/hooks/lendocrWhen each job finishes we POST to your webhook_url (https only), retrying for about a day if your server is down. The body has no document data; fetch the result withGET /v1/jobs/{job_id}. Verify the X-LendOCR-Signature header with your webhook secret:
import hashlib, hmac, time
def verify(secret: str, header: str, body: bytes) -> bool:
parts = dict(p.split("=", 1) for p in header.split(",")) # t=...,v1=...
if abs(time.time() - int(parts["t"])) > 300: # reject replays
return False
mac = hmac.new(secret.encode(), f"{parts['t']}.".encode() + body, hashlib.sha256)
return hmac.compare_digest(mac.hexdigest(), parts["v1"])