sohopay package is the official Python client for the SohoPay API. It mirrors the TypeScript SDK — same resources, same behavior, snake_case methods — with automatic retries and per-request idempotency built in.
Installation
Initialize the client
Pass your API key and, optionally, the target environment. The environment selects the base URL for you — use ask_test_ key with sandbox and a sk_live_ key with mainnet.
Quick example
The canonical flow: create an agent with a credit line, create an order, submit the payment, and verify the settlement webhook when it arrives.payment.settled webhook instead of polling. The SDK validates the HMAC-SHA256 signature and timestamp for you:
Method reference
All methods are snake_case and parameters mirror the API Reference field names exactly.Error handling
Every non-2xx response raises aSohoPayError exception carrying the API’s error code, the HTTP status, and the request_id to quote in support tickets. See Errors for the full code list.
Advanced
- Automatic retries — network failures,
429, and5xxresponses are retried with exponential backoff (respectingRetry-After). Configure withmax_retriesin the constructor; setmax_retries=0to disable. - Idempotency — the SDK generates a unique
Idempotency-Keyper POST request and reuses it across retries, so a retried payment can never settle twice. Passidempotency_key=on any call to control it yourself. - Typed models — responses are typed dataclass-style models with attribute access (
agent.agent_id,payment.settlement_tx); call.to_dict()when you need plain dictionaries.
A Go SDK and a
sohopay CLI are on the roadmap but not yet shipped. Until then, generate clients from the OpenAPI spec — see OpenAPI Tools.Next steps
TypeScript SDK
The same client surface for Node.js and TypeScript.
Code Examples
Runnable, CI-tested examples for every core flow.
Error Handling Guide
Retry strategies and recovery patterns for every error code.

