Python SDK
Official Python SDK for Shim. One dependency (httpx). Sync and async clients included.
Installation
pip
poetry
uv
Quick Start
Client Configuration
Sync
Async
api_key(str, required): Your Shim API keybase_url(str, optional): API base URL. Default:https://api.shim.so
Batch Repair
Sync
Async
With Schema Validation
Streaming Repair
stream.start()
Start a new streaming session. Schema and mode are set here — not on push.
stream.push()
Push a chunk. Returns the current streaming state.
stream.finalize()
Close the session. Returns the full repair response.
Complete Streaming Example
Sync
Async
Type Hints
The SDK ships with full type definitions. All response objects are dataclasses.| Type | Description |
|---|---|
RepairResponse | Top-level batch/finalize response |
RepairMetadata | Confidence, repairs, warnings, errors |
RepairDetail | Single repair operation (type, confidence, field) |
Warning | Non-critical issue |
RepairError | Critical failure with recoverability flag |
StreamSession | Session ID + expiry from stream.start() |
StreamingState | Incremental parse state from stream.push() |
Error Handling
The SDK raiseshttpx.HTTPStatusError for transport-level failures. Shim itself always returns HTTP 200 — application errors are in the response body.
Next Steps
Batch Endpoint
API reference for batch repair
Streaming Endpoints
API reference for streaming repair
Response Object
Full response schema
TypeScript SDK
Node.js / browser SDK
