Metadata-Version: 2.4
Name: thresh-sdk
Version: 0.7.0
Summary: Official Python client for the Thresh document extraction API
Requires-Python: >=3.9
Requires-Dist: httpx>=0.27
Description-Content-Type: text/markdown

# thresh-sdk

Official Python client for the [Thresh](https://github.com/Fillnull/thresh)
document extraction API — documents in, schema-conformant JSON out.

```python
from thresh import Thresh

client = Thresh(api_key="th_live_...")
doc = client.upload(
    "contract.pdf",
    fields=["purchase_price", "closing_date", "buyer_name"],
    tables=[{"name": "monthly_charges", "columns": ["item", "qty", "mrc"]}],
    questions=["Is the contract contingent upon financing?"],
)
result = client.wait(doc.id)

result.fields["purchase_price"]        # "399900"
result.tables["monthly_charges"]       # [{"item": ..., "qty": ..., "mrc": ...}, ...]
result.answer("Is the contract contingent upon financing?")  # "Yes"
```

- `upload(...)` accepts a path or a binary file object; pass `idempotency_key=`
  to make retries safe.
- No schema? `client.upload("contract.pdf")` runs auto-extraction: the engine
  discovers and names the fields and tables itself. Refine what it found, then
  `client.create_template("sale-contract", fields=[...])` and reuse it with
  `client.upload("next.pdf", template="sale-contract")`.
- `wait(id, timeout=300)` polls until `completed` or `failed` (failed results
  return with `.error` set — no exception).
- `verify_webhook_signature(secret, header, body)` validates
  `Thresh-Signature` headers on webhook deliveries.
- Errors raise `ThreshError` with `.status`, `.error_type`, and `.request_id`.

Missing values come back as the string `"null"`; checkbox states as
`"true"`/`"false"`.
