Skip to main content

parserail

Official Python SDK for ParseRail — the AI back-end for your product. Parse documents, extract fields, redact PII, analyze contracts, fight chargebacks, and enrich companies.

pip install parserail

Quickstart

from parserail import ParseRail

client = ParseRail(api_key="ksk_live_...")

doc = client.parse(file_url="https://.../invoice.pdf")
print(doc["totalAmount"])              # 4820.5
print(doc["usage"]["balanceRemaining"])  # 490

Get a key (and 500 free credits) at parserail.thecompound.tech. Zero dependencies — stdlib only, Python 3.8+.

Methods

Every method returns the endpoint result as a dict, including a usage envelope. A non-2xx response raises a typed ParseRailError (and never burns credits).

client.parse(file_url=...)                                  # documents → JSON
client.extract(text=..., fields=["order", "total"])         # pull named fields
client.classify(text=..., labels=["billing", "tech"])       # label text
client.summarize(text=..., length="standard")               # summary + actions
client.redact(text=...)                                      # strip PII/PHI
client.sentiment(text=..., aspects=["product"])             # sentiment + aspects
client.contract(file_url=...)                               # contract → terms + risks
client.chargeback(reason=..., transaction={"amount": 129})  # representment packet
client.enrich(email="sam@stripe.com")                       # company profile
client.account()                                            # balance

Async & webhooks

A hundred-page contract doesn't fit in a request/response cycle. The document endpoints — parse, invoice, receipt, statement, resume, tables, split, compare, contract — take async_=True and hand you a job instead of a result. (async is a Python keyword, hence the trailing underscore; the wire field is async.)

job = client.parse(file_url="https://.../contract.pdf", async_=True)
done = client.wait_for_job(job["jobId"])

if done["status"] == "succeeded":
    print(done["result"]["totalAmount"])
else:
    print(done["error"])          # failed jobs are never charged

Use client.get_job(job_id) for a single poll if you'd rather drive the loop yourself.

Every job reaches a terminal state. If the instance running yours dies mid-flight, it is marked failed with an explanation rather than left running forever — and you aren't billed for it. Nothing is silently retried; resubmit and you stay in control of the spend.

Webhooks

Pass a callback_url (public https) and the finished job is POSTed to it, signed with your account's webhook secret from the API keys page:

client.parse(file_url=..., async_=True, callback_url="https://you.example/hooks/parserail")
import hmac, hashlib

# X-ParseRail-Signature: sha256=<hex HMAC-SHA256 of the RAW body>
def verify(raw_body: bytes, header: str, secret: str) -> bool:
    expected = hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(header.removeprefix("sha256="), expected)

Delivery is best-effort and never retried — polling is the source of truth.

Error handling

from parserail import ParseRail, ParseRailError

client = ParseRail(api_key="ksk_live_...")
try:
    client.parse(file_url="https://.../invoice.pdf")
except ParseRailError as err:
    # err.code: "insufficient_credits" | "rate_limited" | "unauthorized" | ...
    print(err.code, err.status, err.message)

MIT © ParseRail Studios

Metadata

Release files for parserail 0.6.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 parserail 0.6.0
File Size Uploaded Provenance
parserail-0.6.0.tar.gz 8.4 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 17.5 kB

Release files / parserail-0.6.0.tar.gz

Download URL parserail-0.6.0.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4e81a960ea796b8384d827e370f05ce733e64f52bb3cfb22fed772dbe76fde6b
BLAKE2b-256 checksum
How to use checksums
91438d1becb6047eae9245e5d62153ee73522e231e145cde6e84b86f49f38561
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / parserail-0.6.0-py3-none-any.whl

Download URL parserail-0.6.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c0de5a7481e524af85c5ec775c54d9776e5d07560bb24e84666e99317574b51
BLAKE2b-256 checksum
How to use checksums
bdc8047daa558196a611ead7b3ce8ae35602913e5594ee83a8c60bc1ce9b5ea5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for parserail 0.6.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.

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