Skip to main content
FastOCR

Python client for the FastOCR Document OCR API. Send a scanned PDF or an image, get back its text or a searchable PDF.

CI PyPI Python License: MIT

Website · Docs · Get an API key

FastOCR reads a scanned page in English, Arabic and Hindi and returns its text

Install

pip install fastocr-sdk
export FASTOCR_API_KEY="your_api_key"

Python 3.9 or newer. The distribution is fastocr-sdk and the import is fastocr_sdk. Do not install the unrelated fastocr package from PyPI.

Quickstart

from fastocr_sdk import FastOCR

with FastOCR() as client:
    print(client.extract_text("scanned_contract.pdf"))

extract_text uploads the file, runs OCR, waits for it to finish, and returns the text. Images work the same way; pass filename when you send bytes.

What you get back

You get How
The text of the document client.extract_text(file)
A searchable PDF client.documents.download_searchable_pdf(job.id, "out.pdf")
Status and page counts job.status, job.pages_billed, job.pages_total

Examples

Runnable scripts are in examples/, with RAG, archiving and cURL recipes in examples/cookbooks/. Full reference →

Searchable PDF

with FastOCR() as client:
    job = client.documents.process("scanned_archive.pdf")
    client.documents.download_searchable_pdf(job.id, "searchable.pdf")

Async and batches

import asyncio
from fastocr_sdk import AsyncFastOCR

async def main():
    async with AsyncFastOCR() as client:
        print(await client.extract_text("invoice.pdf"))

asyncio.run(main())

Accounts process 2 documents at once by default. Cap concurrency with a semaphore, as in examples/async_batch.py.

Errors

Every error is a FastOCRError with status_code, code, request_id and message. Branch on code, never on message.

from fastocr_sdk import DocumentFailedError, FastOCR, FastOCRError

with FastOCR() as client:
    try:
        text = client.extract_text("scan.pdf")
    except DocumentFailedError as error:
        print(error.code, error.retryable, error.document_id)
    except FastOCRError as error:
        print(error.status_code, error.code, error.request_id)

If the account runs out of pages partway, extract_text raises PartialResultError instead of returning truncated text; pass allow_partial=True to accept it. Transient failures are retried and a document is never created twice.

Exception classes
Exception When
AuthenticationError HTTP 401 or 403
BadRequestError HTTP 400
NotFoundError HTTP 404
DocumentConflictError HTTP 409
RateLimitError HTTP 429, after retries
ServerError, APIConnectionError HTTP 5xx or no response, after retries
DocumentFailedError The document reached status failed
PartialResultError The document was only partly processed

Full reference: retries, idempotency, out-of-pages recovery, configuration.

RAG integrations

Use langchain-fastocr for LangChain or llama-index-readers-fastocr for LlamaIndex. Both are built on this SDK.

Languages and files

  • 100+ languages, detected automatically. No language setting is needed.
  • PDF files up to 1 GiB, and PNG, JPG, JPEG, GIF, WebP and BMP images up to 20 MiB. An image counts as one page.
  • Sync (FastOCR) and async (AsyncFastOCR) clients. One runtime dependency: httpx.

Pages and pricing

Any signed-in FastOCR account can create an API key and start right away. Create one in the developer console; you accept the API terms with your first key. Each account gets 50 free document pages per month. When you need more, buy a prepaid API page pack by card in the developer console.

Support and license

Questions: support@fastocr.org. Bugs and requests: GitHub issues. Full reference: docs/reference.md. MIT license; see LICENSE.

Metadata

Release files for fastocr-sdk 0.2.1

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

Source distribution (sdist)

Source distribution for fastocr-sdk 0.2.1
File Size Uploaded Provenance
fastocr_sdk-0.2.1.tar.gz 3.2 MB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fastocr-sdk 0.2.1
File Interpreter ABI Platform
fastocr_sdk-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 3.2 MB

Release files / fastocr_sdk-0.2.1.tar.gz

Download URL fastocr_sdk-0.2.1.tar.gz
Size 3.2 MB
Tags Source
SHA-256 checksum
How to use checksums
b0ad8e2f8aa9e5c02372c724f78cb949489a997008bc9090ba137f7978846feb
BLAKE2b-256 checksum
How to use checksums
302d8478910e360f3e5be6cc1f14bc7644c4e5a1003f7363634b501a69b09198
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 Oct 25, 2026.

Transparency log

Release files / fastocr_sdk-0.2.1-py3-none-any.whl

Download URL fastocr_sdk-0.2.1-py3-none-any.whl
Size 20.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5060d6358c304142259cfb8e2b9f86d56d7c81c5e061b708da502f7e6bb13559
BLAKE2b-256 checksum
How to use checksums
32fac3669bbedf242c50df16f91a2ec4dbc6a17e9038188503fef4b99231dcf4
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 Oct 25, 2026.

Transparency log

Security for fastocr-sdk 0.2.1

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fastocr_sdk-0.2.1.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 Oct 25, 2026.

Transparency log

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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