SDK WebSocket Usage
The same client handles live subscriptions and replay. The connection model matches the WebSocket docs.
Use the official clients for typed requests across market data, order-level routes, data-quality monitoring, and wallet/web3 flows.
WebSocket usage
The same client handles live subscriptions and replay. The SDK examples follow the same connection model as the WebSocket docs.
import asynciofrom oxarchive import OxArchiveWs, WsOptions
async def main(): ws = OxArchiveWs(WsOptions(api_key="0xa_your_api_key"))
# Subscribe to real-time data ws.on_orderbook(lambda coin, data: print(f"{coin}: {data.mid_price}"))
await ws.connect() ws.subscribe_orderbook("BTC")
# Or replay historical data await ws.replay("orderbook", "BTC", start=1704067200000, speed=10)
asyncio.run(main())