Pre-release — 0.1.x. Sync HTTP, async HTTP, and WebSocket clients with typed Pydantic v2 response models are available today. API-key auth is in progress.
stx-python is the official Python SDK for the SportsX trading exchange. It wraps the GraphQL HTTP API and Phoenix WebSocket channels behind a small, ergonomic surface:
STX— synchronous GraphQL clientAsyncSTX— asyncio-native GraphQL client (same surface asSTX)STXWebSocket— Phoenix channels client with reconnect, heartbeat, and resubscribe baked in
Where to go next
Quickstart
Install, authenticate, and make your first call in under five minutes.
Installation
Supported Python versions, optional extras, and platform notes.
Authentication
Email/password login, 2FA, env vars, and profile files.
Configuration
Regions, environments,
~/.stx/credentials profiles, and schema pinning.Market data
Query markets, orderbooks, and event metadata.
Trading
Place, cancel, and inspect orders; fetch positions and fills.
WebSockets
Subscribe to Phoenix channels for real-time order and market updates.
Async
The same API as
STX, awaitable — for bots and high-fanout services.Errors & retries
Exception hierarchy, the built-in retry policy, and how to override it.
API reference (compact)
Every operation on one page — Ctrl-F index to all 64 queries and mutations.
API reference (by category)
Per-category pages with parameters tables and examples for each op.
Design goals
- Zero-config defaults.
client.marketInfos()returns every scalar field by default — REST-like. Narrow the payload withSelection(...)only when you care. - Typed responses out of the box. Every response is a Pydantic v2 model —
.marketId,.status, full IDE autocomplete, and.model_dump()if you need a dict. - Typed operations too. Method names (
client.marketInfos,client.confirmOrder) andparams=keys autocomplete in VS Code / Pyright / mypy. Typos fail type-check before you run your code. - One set of credentials, three clients. The
Usersingleton caches the JWT, soSTX,AsyncSTX, andSTXWebSocketshare auth in a single process. - Auto-refreshed tokens. JWTs expire after 60 minutes; the SDK refreshes at 59 so you don’t see
STXTokenExpiredExceptionin steady-state code. - Typed exceptions.
STXAuthException,STXRateLimitException,STXValidationException, and friends — not a single catch-allAPIError. - Schema pinned to your SDK version. The GraphQL schema ships with the package; upgrade the SDK to pick up new fields. Opt into always-latest mode when you need bleeding-edge fields.
Compatibility
| Supported | |
|---|---|
| Python | 3.11, 3.12, 3.13 (3.9, 3.10 best-effort) |
| OS | Linux, macOS, Windows |
| Async runtime | asyncio (native); trio/anyio via compat layer (not tested) |
Example gallery
Working end-to-end examples live instxapp/stx-python-demo:
quickstart.py— minimum viable first calllist_markets.py— comparison of narrowSelectionvs. default-all-fields payload sizesplace_order.py— order placement with dry-run modewebsocket_feed.py— subscribe to live market updates over Phoenix
Support
- Bug reports / feature requests: github.com/stxapp/stx-python/issues
- Questions: post in the #developers channel on the SportsX Discord

