requests library under the hood, requires no framework-specific setup, and works in any Python 3.7+ environment — from a Django backend to a standalone data-processing script.
Installation
Install the package from PyPI with pip:The package is published as
parsetx (no scoping needed on PyPI). It depends only on the requests library, which is installed automatically.Initialization
ImportParseTxClient and instantiate it with your API key. The client creates a persistent requests.Session and attaches your key to every outgoing request via the X-API-Key header automatically.
Synchronous Enrichment
Useclient.enrich() when you need results right away. It sends up to 10 transaction strings to POST /v1/enrich and returns the fully enriched response as a Python dictionary.
status field tells you how to handle it:
| Status | Meaning |
|---|---|
complete | Enrichment succeeded — all merchant fields are present. |
rejected | Input was high-entropy, too short, or all PII after sanitization. |
retry | A transient processing fault occurred for this item only. |
Max batch size
Up to 10 items per synchronous call. Passing more raises a
ValueError before any network request is sent.Response time
Cached merchants typically resolve in under 50 ms. New merchants route through the LLM pipeline and may take a moment longer.
Asynchronous Batch Enrichment
For batches larger than 10 items, useclient.enrich_async(). It submits up to 500 transaction strings to the background processing queue and returns a job_id string immediately — you don’t wait for results at submission time.
Each async batch is capped at 500 items. For datasets larger than 500 items, split your list into chunks of ≤ 500 and call
enrich_async() once per chunk.Polling for Async Results
Pass yourjob_id to client.poll_job() to retrieve the finished results. The method polls GET /v1/enrich/jobs/:id in a loop and returns only when the job status reaches "complete" or "failed". It applies exponential backoff automatically — starting at a 2-second interval, multiplying by 1.5 on each pass, and capping at 10-second intervals.
Polling options
| Parameter | Type | Default | Description |
|---|---|---|---|
interval_ms | int | 2000 | Initial delay between poll attempts, in milliseconds. |
max_wait_ms | int | 120000 | Maximum total wait time before a ParseTxError is raised (2 minutes). |
Complete Async Workflow
Environment Variable Pattern
Loading credentials from environment variables is the standard practice for any application you deploy or share. SetPARSETX_API_KEY once in your environment and reference it everywhere:
.env file with a library like python-dotenv:
Method Reference
ParseTxClient(api_key, base_url?)
Creates a new client instance.
api_key (str, required) is your pt_live_... key. The optional base_url argument overrides the default https://api.parsetx.com.client.enrich(transactions)
Synchronously enriches a list of up to 10 raw transaction strings. Returns a
dict with a results list, a job_id of None, and a status string.client.enrich_async(transactions)
Submits a list of up to 500 raw transaction strings for background processing. Returns a
str — the job_id you use to retrieve results.client.poll_job(job_id, interval_ms?, max_wait_ms?)
Polls
GET /v1/enrich/jobs/:id with exponential backoff until the job reaches "complete" or "failed". Returns a dict with the same shape as a sync enrich() response.