Python SDK: Batches
Asynchronous processing at the batch price.
from syntic import Syntic
client = Syntic() # reads SYNTIC_API_KEY| Method | Endpoint | Returns |
|---|---|---|
batches.create | POST /v1/batches | Batch |
batches.list | GET /v1/batches | SyncPage[Batch] |
batches.retrieve | GET /v1/batches/{batch_id} | Batch |
batches.wait | (helper; polls GET /v1/batches/{batch_id}) | Batch |
batches.results | GET /v1/batches/{batch_id}/results | Iterator of BatchResult |
batches.cancel | POST /v1/batches/{batch_id}/cancel | Batch |
batches.delete | DELETE /v1/batches/{batch_id} | BatchDeleted |
Methods
batches.create
From an uploaded JSONL input_file_id, or up to 1,000 inline requests. Maps to POST /v1/batches.
result = client.batches.create(input_file_id="file_01JBXF1Z")batches.list
List batches. Maps to GET /v1/batches.
for item in client.batches.list(limit=20):
print(item.id if hasattr(item, 'id') else item)batches.retrieve
Status and counts. Maps to GET /v1/batches/{batch_id}.
result = client.batches.retrieve('batch_01JBXF3P8K')batches.wait
Helper: poll until the batch ends, with back-off. Returns the final batch.
result = client.batches.wait('batch_01JBXF3P8K', poll_interval=30)batches.results
Iterate result lines as typed objects, streaming from the server. Maps to GET /v1/batches/{batch_id}/results.
for item in client.batches.results('batch_01JBXF3P8K'):
print(item.id if hasattr(item, 'id') else item)batches.cancel
Cancel a running batch. Maps to POST /v1/batches/{batch_id}/cancel.
result = client.batches.cancel('batch_01JBXF3P8K')batches.delete
Delete an ended batch and its result files. Maps to DELETE /v1/batches/{batch_id}.
result = client.batches.delete('batch_01JBXF3P8K')Conventions
Every method accepts extra_headers, extra_query, extra_body and timeout keyword arguments, and has an async twin on AsyncSyntic. List methods return pages that iterate across all pages automatically.
See the Python SDK overview for installation, errors and retries.