StructOCR Python SDK
Official Python client for the StructOCR API.
Extract validated, structured JSON from 22 document & verification endpoints — spanning identity & KYC (US/Canadian front+back driver license verification, PDF417 barcodes, driver licenses, passports, travel visas, proof of address, national IDs, health insurance cards), general documents (multi-page PDF table/JSON extraction, Image to Excel), vehicles & insurance (VIN, VIN Pro vehicle decode, license plates, vehicle registrations including Saudi Istimara & UAE Mulkiya, auto insurance cards), finance (multi-page PDF invoices, receipts), and logistics (bills of lading, shipping containers, weighbridge tickets, ATM cassettes, boat HINs). One method call per document, zero template training, pay-as-you-go credits that never expire.
Get a free API key
- Create an account. New accounts get 200 permanent free credits (50 full driver license verifications or 100 two-credit document scans), with no credit card required.
- Copy your key from API Keys in the dashboard.
- Optionally test any endpoint on a sample document in the Playground before writing code.
After the free credits, packs start at $5 for 500 credits ($0.0058–$0.01/credit). There is no monthly subscription and credits never expire. See pricing.
Supported documents & endpoints
| Document / Workflow | Method | Credits | Zero Retention | Try it |
|---|---|---|---|---|
| US/Canada driver license verify (front OCR + back PDF417) (New) | verify_driver_license |
4 | Yes | Try it |
| PDF table & JSON extraction (up to 20 pages) (New) | extract_pdf |
2 / page | Yes | Try it |
| Image to Excel table extraction (New) | image_to_excel |
2 / image | Yes | Try it |
| US/Canada driver license PDF417 barcode | scan_driver_license_pdf417 |
2 | Yes | Try it |
| Driver license (front) | scan_driver_license |
2 | — | Try it |
| Passport (MRZ + visual) | scan_passport |
2 | — | Try it |
| National ID card | scan_national_id |
2 | — | Try it |
| Health insurance card | scan_health_card |
2 | Yes | Try it |
| Proof of Address | scan_proof_of_address |
2 | Yes | Try it |
| Travel visa (MRV-A/B & eVisa) | scan_visa |
2 | Yes | Try it |
| VIN | scan_vin |
1 | — | Try it |
| VIN Pro (VIN + vehicle details) | scan_vin_pro |
2 | — | |
| License plate | scan_license_plate |
1 | — | Try it |
| Vehicle registration (Istimara, Mulkiya, global) | scan_vehicle_registration |
2 | — | Try it |
| Auto insurance card | scan_auto_insurance |
2 | — | Try it |
| Invoice (multi-page PDF up to 5 pages) | scan_invoice |
3 | — | Try it |
| Receipt | scan_receipt |
1 (2 enhanced) | — | Try it |
| Shipping container (ISO 6346) | scan_container |
1 | — | Try it |
| Bill of Lading & freight | scan_bill_of_lading |
3 | — | Try it |
| Weighbridge ticket | scan_weighbridge_ticket |
2 | — | Try it |
| ATM cassette | scan_atm_cassette |
1 | — | |
| HIN (boat hull number) | scan_hin |
1 | — | Try it |
Only successful requests are charged. Failed pages on extract_pdf / image_to_excel and unreadable back barcodes (HTTP 422) on verify_driver_license are automatically refunded.
What's new in v1.9.0
verify_driver_license(front, back, *, min_age=None)(POST /v1/driver-license-verify, 4 credits, strict Zero Data Retention) — Single-call US & Canadian front OCR + back AAMVA PDF417 cross-check, Document Discriminator (DDvs.DCF), expiry, and18+/21+/min_ageverification. Back barcode decodes first; unreadable barcodes return HTTP 422 withfailed_side/capture_issueand auto-refund all 4 credits. Card-level consistency check only (does not query DMV registries).extract_pdf(file, *, mode="auto", pages=None, schema=None, stitch_tables=None)(POST /v1/pdf-extract, 2 credits/succeeded page, strict Zero Data Retention) — Nativemultipart/form-dataupload up to 10 MB / 20 pages with multi-page table stitching and optional custom schema extraction.image_to_excel(file, *, mode="tables", ...)(POST /v1/image-to-excel, 2 credits/image, strict Zero Data Retention) — Converts table photos and scanned sheets into deterministicheaders[]androws[][]arrays.- Native Apple HEIC/HEIF support — Local format detection now accepts iPhone
HEIC/HEIFimages forverify_driver_license,scan_driver_license_pdf417, and standard image endpoints (while still rejecting unsupported formats such as AVIF before sending).
Install
pip install --upgrade structocr
Python 3.7+ is required.
Quick start
export STRUCTOCR_API_KEY="YOUR_API_KEY"
Verify US/Canadian driver license (Front OCR + Back PDF417)
from structocr import StructOCR, StructOCRError
client = StructOCR()
try:
result = client.verify_driver_license(
"./license-front.jpg",
"./license-back.heic",
min_age=21,
)
v = result["data"]["verification"]
print(v["overall_status"], "DD/DCF:", v["dd_dcf_match"], "21+:", v["meets_min_age"])
except StructOCRError as err:
if err.status_code == 422 and isinstance(err.details, dict):
# Unreadable back barcode short-circuits with full 4-credit refund
print("Retake:", err.details.get("failed_side"), err.details.get("capture_issue"))
else:
raise
Extract tables from a multi-page PDF or photo
from structocr import StructOCR
client = StructOCR()
pdf_res = client.extract_pdf("./statement.pdf", mode="tables", pages="1-5")
for table in pdf_res["document"]["tables"]:
print(table["headers"], len(table["rows"]))
img_res = client.image_to_excel("./price-sheet.jpg")
print(img_res["document"]["tables"][0]["rows"])
Scan a passport (or pass in-memory bytes)
from structocr import StructOCR
client = StructOCR()
result = client.scan_passport("./passport.jpg")
if result.get("success"):
data = result["data"]
print(data.get("passport_number"))
print(data.get("given_names"), data.get("surname"))
FastAPI and other server frameworks can pass uploaded bytes without a temporary file:
content = await upload.read()
result = client.scan_passport(content)
Methods
verify_driver_license(front, back, *, min_age=None)
extract_pdf(file, *, mode="auto", pages=None, schema=None, stitch_tables=None)
image_to_excel(file, *, mode="tables", pages=None, schema=None, stitch_tables=None)
scan_passport(file)
scan_national_id(file)
scan_driver_license(file)
scan_driver_license_pdf417(file)
scan_health_card(file)
scan_proof_of_address(file)
scan_visa(file)
scan_vin(file)
scan_vin_pro(file)
scan_license_plate(file)
scan_vehicle_registration(file)
scan_auto_insurance(file)
scan_invoice(file)
scan_receipt(file, response_version=None, accuracy="standard")
scan_container(file)
scan_bill_of_lading(file)
scan_weighbridge_ticket(file)
scan_atm_cassette(file)
scan_hin(file)
get_account_balance()
- Single-document
scan_*methods accept a local path or bytes up to 4.5 MB (JPG, PNG, WebP, HEIC, and PDF;scan_driver_license_pdf417andverify_driver_licenseaccept JPG, PNG, WebP, and HEIC). extract_pdfandimage_to_excelsendmultipart/form-dataup to 10 MB (PDF, JPG, PNG, and WebP).
Machine-Readable Specs & Automation
- OpenAPI 3.1 Spec:
https://structocr.com/openapi.json - LLM Documentation Index:
https://structocr.com/llms.txt·https://structocr.com/llms-full.txt - n8n Workflow Guides: Driver License Verification · Image to Excel · Saudi Istimara
- API Reference:
https://structocr.com/developers
Configuration
client = StructOCR(
api_key="YOUR_API_KEY",
base_url="https://api.structocr.com/v1",
timeout=60,
)
Errors
API and network failures raise StructOCRError. Existing except RuntimeError code continues to work because StructOCRError extends RuntimeError.
from structocr import StructOCRError
try:
client.scan_passport("./passport.jpg")
except StructOCRError as error:
print(error.status_code, error.code, error.retryable)
retryable is advisory only. The SDK does not automatically retry OCR requests because doing so without an idempotency key could charge a request twice.
License
MIT
Metadata
Release files for structocr 1.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| structocr-1.9.0.tar.gz | 13.9 kB | With provenance | Details for structocr-1.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| structocr-1.9.0-py3-none-any.whl | Python 3 | none | any | Details for structocr-1.9.0-py3-none-any.whl |
Total release size: 24.5 kB
Release files / structocr-1.9.0.tar.gz
| Download URL | structocr-1.9.0.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a8d7a5b9b5f5ba525f044ce2a8cff95ca849c5fe42634a9b71eaf2e4a0a5cee
|
|
BLAKE2b-256 checksum How to use checksums |
b1b3e57518ae96c508544ace9a093e0bc5546a47407422f6d4394699692490d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / structocr-1.9.0-py3-none-any.whl
| Download URL | structocr-1.9.0-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e56f410c13ded075f7a94bd211d3368075f286a526d635eeab255994dd38869b
|
|
BLAKE2b-256 checksum How to use checksums |
f58349d5bc7a1ac53da9dcd3ba4a23fb0671c1f8c29809dbe9f3a5dc03354747
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logSecurity for structocr 1.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for structocr-1.9.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.