Python ships async (AsyncPolyester) and sync (Polyester) clients with the same service tree. Prefer async for bots with streams.
Process lifecycle
- Create one client per process (or per logical bot) and reuse it.
- Close / drop the client on shutdown so HTTP and WebSocket pools release cleanly
(Python context managers, Go
Close(), Rust drop). - Cancel work with async cancellation (Python task cancel),
context.Context(Go), or Tokio cancellation (Rust).
Configuration
Prefer explicit credentials from your secret store. Use from_env / FromEnv only for local
scripts.
Wait for catalogs before decimal writes. Disable catalog hydration only if you exclusively use pre-scaled integers and understand the tradeoff.
Wire format
Binary Protobuf is the default Connect codec. JSON wire formats are for debugging, not hot paths. If you enable JSON, API-key signatures hash the codec-encoded JSON body bytes that are actually sent, not a separately marshaled protobuf blob. A body/signature mismatch fails auth.
See Client configuration.
Related Topics
Authentication Configure Ed25519 API keys, Account ID, and env-based wiring for bots. Market data Read candles, public trades, order books, and market overview, no credentials required. Trading Place, modify, cancel, and batch spot orders; use triggers and risk attachments. Streaming Subscribe to public and private WebSocket Protobuf channels with async iterators, handshake-before-return, and fail-closed overflow. Accounts & balances Funding vs trading balances, holds, subaccounts, policies, and transfer history. Deposits & withdrawals Deposit addresses, trading withdraws, internal transfers, lifecycle, and chain helpers. Error handling Classify failures, retry safely with idempotency keys, and handle realtime overflow. Production trading operations Operate, test, troubleshoot, and upgrade an automated Python trading system safely.