Skip to main content
FastOCR

Python client for the FastOCR API. Send a scanned PDF or an image, get back its text or a searchable PDF. Send a bank statement, get back Excel, CSV, JSON or QuickBooks files.

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
A bank statement as Excel, CSV, JSON or QuickBooks files (beta) client.extract_statement(file), then client.bank_statements.save(job.id, "out.xlsx", "xlsx")
Pages left on the account client.get_balance().pages_remaining, statement_pages_remaining

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")

Bank statements (beta)

with FastOCR() as client:
    job = client.extract_statement("statement.pdf")          # upload, then wait for the result
    print(job.pages_billed, job.needs_review)
    client.bank_statements.save(job.id, "statement.xlsx", "xlsx")
    data = client.bank_statements.json(job.id)               # accounts, balances and transactions

Formats: json, csv, xlsx, qbo, quickbooks_csv, qfx and ofx. For a statement with several accounts, pass account=2 (1 is the first) to save or download for the accounting formats. job.outputs["xlsx"].url is a download link that works for one hour; call client.bank_statements.get(job.id) again for fresh links. If extraction fails, extract_statement raises StatementFailedError (a DocumentFailedError) with the failure code. Statements take PDF, PNG, JPG, JPEG and WebP files, and their pages come from a balance of their own, shared with the website's bank statement converter. A runnable script is in examples/extract_bank_statement.py.

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
StatementFailedError The bank statement reached status failed (a DocumentFailedError)
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, and both read bank statements too (one document per transaction).

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. Every account gets 20 free pages a month, shared with PDFs on the website, and an image sent to the API is one page. When you need more, buy a Page Pack on the pricing page. Packs and the page balance are the same on the website and in the API. Bank statement pages are a separate balance that new accounts start with some free pages in; check both with client.get_balance().

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.4.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 fastocr-sdk 0.4.0
File Size Uploaded Provenance Actions
fastocr_sdk-0.4.0.tar.gz 3.2 MB With provenance Details for fastocr_sdk-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 3.2 MB

Release files / fastocr_sdk-0.4.0.tar.gz

Download URL fastocr_sdk-0.4.0.tar.gz
Size 3.2 MB
Tags Source
SHA-256 checksum
How to use checksums
2cd6c46f846fece3c927fdd9cb4cad103bdcf3160a4ca778edfb2b656c8b7cf1
BLAKE2b-256 checksum
How to use checksums
f32c6fb065955a78f192e178e8f62e8f3e5a2e1a4b85548bc93f660b59f70c34
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 Nov 6, 2026.

Transparency log

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

Download URL fastocr_sdk-0.4.0-py3-none-any.whl
Size 25.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56488f39002efa67e5f5c7d97e411bc6b4ac81d8deaf6e8d286da6eeaebad935
BLAKE2b-256 checksum
How to use checksums
dbdc1f68352f676b9eb453feeb189fe0f74e2102ca8afd09af6c24074c6b8156
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 Nov 6, 2026.

Transparency log

Security for fastocr-sdk 0.4.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.

Select from 2 files

Attestation for fastocr_sdk-0.4.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 Nov 6, 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