Skip to main content

StructOCR Python SDK

Official Python client for the StructOCR API.

The SDK accepts a local JPG, PNG, WebP, or PDF path, plus in-memory bytes. It validates the decoded file locally, converts it to Base64, and sends the API's required JSON payload: {"img": "..."}. The REST API itself does not accept file paths, bytes, URLs, or multipart uploads.

Install

pip install --upgrade structocr

Python 3.7+ is required.

Quick start

export STRUCTOCR_API_KEY="YOUR_API_KEY"
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"))

PDF paths work the same way:

result = client.scan_invoice("./invoice.pdf")

FastAPI and other server frameworks can pass uploaded bytes without a temporary file:

content = await upload.read()
result = client.scan_passport(content)

Methods

scan_passport(file)
scan_national_id(file)
scan_driver_license(file)
scan_invoice(file)
scan_receipt(file)
scan_vin(file)
scan_hin(file)
scan_container(file)
scan_license_plate(file)
scan_vehicle_registration(file)
scan_atm_cassette(file)
get_account_balance()

All document methods accept a local path or bytes. Supported decoded formats are JPG, PNG, WebP, and PDF, up to 4.5MB.

Configuration

client = StructOCR(
    api_key="YOUR_API_KEY",
    base_url="https://api.structocr.com/v1",
    timeout=60,
)

See the API documentation for endpoint-specific response schemas and error codes.

License

MIT

Metadata

Release files for structocr 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for structocr 1.5.0
File Size Uploaded Provenance
structocr-1.5.0.tar.gz 4.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for structocr 1.5.0
File Interpreter ABI Platform
structocr-1.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.5 kB

Release files / structocr-1.5.0.tar.gz

Download URL structocr-1.5.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6607885743b9a77c9c03d85b3fbc8720675464ad108c6b3009d5ede1f18c41e9
BLAKE2b-256 checksum
How to use checksums
b32106593f6e61b2801f9a488424537e5e5e154e9f33d8444d78d77a1847039f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.9

Release files / structocr-1.5.0-py3-none-any.whl

Download URL structocr-1.5.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbb90a4df7fb24cd04d7296b588ac9c861d681b5d66f03fb3f4866370bedb6f6
BLAKE2b-256 checksum
How to use checksums
2c609a17ae91c121f4b1eb85699f737eec4ff0d980676f8d2967c4dfb0cc77a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.9

Security for structocr 1.5.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page