Skip to main content

patchwell

Transcription, data cleaning and cited web research from Python. Pay per result: a failed or refused call costs nothing. Standard library only, so it runs in Lambda, Airflow, cron jobs and notebooks.

pip install patchwell
export PATCHWELL_KEY=pw_live_...   # a free key with $1 of credit: https://patchwell.io/#try
from patchwell import Patchwell

pw = Patchwell()

# Clean a file, a list of dicts, or several sources merged into one table
clean = pw.clean_data(url="https://example.com/leads.csv")
clean = pw.clean_data(rows=[{"Email": "ANN@X.COM", "Name": "ann lee"}])
clean = pw.clean_data(inputs=[{"url": "https://example.com/crm.csv"}, {"rows": scraped, "name": "web"}])

# Only the rows you haven't sent before, for a daily job
new = pw.clean_data(url=export_url, only_new={"state": "daily-leads", "key": ["Email"]})

# Check rows against your rules and map them onto your import template
ready = pw.clean_data(rows=rows, rules=[{"column": "Age", "range": [0, 120]}],
                      target={"columns": [{"name": "email", "required": True}, {"name": "name"}]})

# Transcribe: waits for long recordings (polls with the server's Retry-After)
t = pw.transcribe("https://example.com/interview.mp3")
print(t["text"])
open("interview.srt", "w").write(t["srt"])

# Research with a cited source for every claim
# ($0.02 per answered question; declined and unanswered questions are free)
a = pw.research("Which EU countries require B2B e-invoicing in 2026?")
print(a["answer"], a["gaps"])

# Hard multi-step questions: depth="deep" searches about twice as wide ($0.06 per answered question).
# private=True keeps the question inside Modal, the cloud Patchwell runs on: same price.
d = pw.research("How old was the author of Dracula when it was published?", depth="deep")
# A worked-out answer's claim has "derived": True, "derived_from" (the facts it rests on) and "calc"

# Results as files
open("clean.xlsx", "wb").write(pw.export(clean, "xlsx"))

# Any tool by name, including tools added after this version: the input is the tool's own JSON body
for name, tool in pw.tools().items():          # every tool, read live from the API
    print(name, tool["price"])
print(pw.describe("research")["input_schema"])   # what a tool takes
r = pw.run("research", ask="Which EU countries require e-invoicing in 2026?", depth="deep")

Retries never charge twice

Every POST carries an Idempotency-Key. On a retryable error (rate_limited, unavailable, a request still running) the SDK waits for Retry-After and sends the same key again, so you get the first response and pay once. Pass your own idempotency_key= (an order or row id) and a later rerun of the same item, by cron or by hand, returns the first result instead of paying again.

Errors

from patchwell import PatchwellError

try:
    pw.clean_data(url=url)
except PatchwellError as e:
    if e.code == "insufficient_credit":
        ...                       # top up at https://patchwell.io/#buy
    print(e.code, e.retryable, e.request_id)

Codes:

invalid_input, unauthorized, insufficient_credit, forbidden, not_found, method_not_allowed, too_large, idempotency_in_progress, idempotency_mismatch, rate_limited, source_unavailable, unavailable, tool_paused, internal, cancelled, expired, network, timeout, job_failed.

source_unavailable: the site hosting your file failed for a moment. A job that fails while you wait raises with the server's own code and retryable.

Long jobs without waiting

job = pw.transcribe(url, wait=False)          # {"status": "running", "job_id": "fc-..."}
result = pw.wait(job["job_id"], timeout=3600)

Or send callback_url= and verify the webhook:

from patchwell import verify_webhook

ok = verify_webhook(secret, request.body, request.headers["Patchwell-Signature"])

The full API reference: https://patchwell.io/quickstart

Metadata

Release files for patchwell 0.2.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 patchwell 0.2.0
File Size Uploaded Provenance Actions
patchwell-0.2.0.tar.gz 12.7 kB Without provenance Details for patchwell-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 22.2 kB

Release files / patchwell-0.2.0.tar.gz

Download URL patchwell-0.2.0.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c510986401fb1b357dec4653c86258a9b91f6ae0abf19562e0cf1788cd1e1d02
BLAKE2b-256 checksum
How to use checksums
d2bf99f1b6247abdfaa87e463c98ef562012e8af6f064a335e84a921cef783a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / patchwell-0.2.0-py3-none-any.whl

Download URL patchwell-0.2.0-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b8ce491aac4fcac19cdd87728084902046bd5d6e9a5139a2c8e56a34e5a32e8
BLAKE2b-256 checksum
How to use checksums
b4ff5735bca6f246001d5c305442e4c0891b2754eb5f248e4a57c0284998af9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for patchwell 0.2.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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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