Metadata-Version: 2.5
Name: thresh-sdk
Version: 0.9.1
Summary: Official Python client for the Thresh document extraction API
Project-URL: Homepage, https://usethresh.com
Project-URL: Documentation, https://usethresh.com/guide/sdk
Project-URL: API reference, https://usethresh.com/docs
License-Expression: MIT
License-File: LICENSE
Keywords: api-client,data-extraction,document-extraction,ocr,pdf
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Text Processing :: General
Requires-Python: >=3.9
Requires-Dist: httpx>=0.27
Description-Content-Type: text/markdown

# thresh-sdk

Official Python client for [Thresh](https://usethresh.com): documents in,
schema-conformant JSON out. Full API reference at <https://usethresh.com/docs>.

```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"`.
