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 at parserail.thecompound.tech. There is no free tier. Credits are bought up front, a $20 pack or a plan from $19/mo. 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.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 parserail 0.6.1
File Size Uploaded Provenance
parserail-0.6.1.tar.gz 8.4 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 17.7 kB

Release files / parserail-0.6.1.tar.gz

Download URL parserail-0.6.1.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
05c23aa5fc1ca040a6877e38466b1284b5d68662fce200fdc81f4f937636d21b
BLAKE2b-256 checksum
How to use checksums
f6a37a5114997e6dda862321d51c06536d7576dc08bdf488d85e2ea21a9b4fdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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

Download URL parserail-0.6.1-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7ef4d7f96d90f9971f6b62b289b008fabc66061202626a532bdf2f4fde2d68c
BLAKE2b-256 checksum
How to use checksums
17f22460c08c94519a17f22b44b3ebeea738104db822823279fd3a06d925ed74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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

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