Call DocuOCR from Python with a few requests calls: POST a PDF or image, start extraction, and read structured JSON back with named fields, tables and confidence scores. No OCR engine to host, no cloud SDK to wire.
The same endpoint reads digital and scanned PDFs, so one code path handles both. Copy the Python below and run it against your own document. Last updated July 2026.
Upload a document to extract
Drop files here or click to upload
Up to 50 files
Uploading...
See the JSON your Python would receive, right in the browser.
To use an OCR API in Python, you send a document to an HTTPS endpoint and read the recognized data back as JSON, all through the requests library that ships with Python. There is no OCR engine to install, no model to train, and with a REST API like DocuOCR no SDK to add. You authenticate with a Bearer API key, POST the file to get a file_id, start an extraction job, then poll or receive a webhook for the result. Because the response is JSON, response.json() turns it into a Python dict of named fields, table rows and confidence scores you can drop straight into a database, a DataFrame or an accounting workflow. The same three calls work for a native PDF, a scanned PDF or a photo, so your code does not branch on how the document was made.
Three requests calls, from a file on disk to structured JSON. Swap in your API key from the dashboard and point it at any PDF or image.
import time, requests
API_KEY = "YOUR_API_KEY"
BASE = "https://docuocr.com/api/documents"
headers = {"Authorization": f"Bearer {API_KEY}"}
# 1. Upload the PDF or image, get a file_id
with open("invoice.pdf", "rb") as f:
up = requests.post(f"{BASE}/upload", headers=headers, files={"file": f})
file_id = up.json()["file_id"]
# 2. Start extraction, get a job hash
job = requests.post(f"{BASE}/extract", headers=headers, json={"file_id": file_id})
job_id = job.json()["extraction_hash"]
# 3. Poll until the JSON is ready
while True:
res = requests.get(f"{BASE}/extraction/{job_id}", headers=headers).json()
if res["status"] == "completed":
break
time.sleep(2)
# res["fields"] and res["tables"] are ready to use
for field in res["fields"]:
print(field["name"], field["value"], field["confidence"])
That is the whole integration. For a production batch, wrap each call in a try or except block, add exponential backoff on HTTP 429, and register a webhook instead of the polling loop so results arrive as each document finishes. The document OCR API reference covers the full request and response shape.
The cloud providers ship a Python SDK; a REST API needs only requests. What you get back differs more than the language does. Package names verified July 2026.
| OCR API | Python package | What it returns | Best for |
|---|---|---|---|
| DocuOCR | requests (plain REST, no SDK) | Named fields, tables and confidence as JSON | Fields plus tables from one call, scans included |
| Google Cloud Vision | google-cloud-vision | Text and bounding boxes, no named fields | Raw text OCR on the Google stack |
| Google Document AI | google-cloud-documentai | Text plus entities, needs a service account | Google-native document pipelines |
| AWS Textract | boto3 | Text, forms and tables as blocks | AWS-stack teams that already use boto3 |
| Azure AI Document Intelligence | azure-ai-documentintelligence | Text, layout and prebuilt-model fields | Azure-stack, prebuilt invoice or receipt models |
| Mistral Document AI | mistralai | Markdown plus structured output | LLM-based parsing of mixed content |
| Tesseract | pytesseract (local, not a hosted API) | Plain text only | Offline, low-volume, no API cost |
The split that matters: raw OCR APIs like Google Cloud Vision return text and coordinates, so you write the field mapping in Python yourself. A document extraction API returns named fields and table rows already, which is most of the code you would otherwise maintain. See the full OCR API pricing comparison for what each costs per 1,000 pages.
Generate a key in the dashboard and send it as a Bearer token in the Authorization header.
POST a PDF, PNG, JPG, TIFF or WEBP to the upload endpoint and read the file_id from the JSON.
POST the file_id to start an async job and get an extraction_hash back.
Poll or receive a webhook, then response.json() gives you fields, tables and confidence.
A Python ETL job posts each incoming file, reads the JSON, and writes fields to a warehouse or database with no manual entry.
A script pulls invoices from an inbox or bucket, extracts totals and line items, and posts them to QuickBooks, NetSuite or an ERP.
A data team turns scanned statements and reports into rows and columns, then loads them into pandas for analysis.
A background worker classifies and reads documents on upload so the rest of the app receives clean structured data.
Research and ops teams convert PDFs into JSON at scale to feed dashboards and models.
A verification flow reads IDs and forms, checks confidence scores, and routes low-confidence values to a human.
The full endpoint reference and response shape.
An honest roundup of OCR APIs for US teams.
Pull tables from PDFs to Excel, CSV or JSON.
Per-1,000-page rates across the market.
File size, page and rate limits by vendor.
Turn PDFs into clean spreadsheets with the tables intact.
Generate an API key, paste the three requests calls above, and read structured JSON back in minutes. No engine to host, no SDK to learn, and a free tier to test the integration before you pay per page.