The websocket API requires a valid API key. You can get one by contacting us.
The WebSocket API is ideal for building real-time trading interfaces, price
tickers, and trade feeds. For historical data or one-time queries, use the
REST API endpoints.
Connection
Connect to the WebSocket endpoint:Channels
The WebSocket API supports three channels:| Channel | Description |
|---|---|
prices | Real-time bid/ask price updates for markets |
trades | Real-time trade execution updates |
orderbook | Real-time orderbook depth updates for markets |
Prices Channel
Subscribe to real-time bid/ask price updates for prediction markets
Trades Channel
Subscribe to real-time trade execution updates
Orderbook Channel
Subscribe to real-time orderbook depth updates
Subscription Management
After connecting, send JSON messages to subscribe or unsubscribe from channels. Each channel maintains independent subscription state.Subscribe to All Markets
Subscribe to receive updates for all markets on a channel:Subscribe to Specific Tickers
Subscribe to receive updates for specific market tickers:Unsubscribe from All Markets
Unsubscribe from all markets on a channel:Unsubscribe from Specific Tickers
Unsubscribe from specific market tickers:Subscription Behavior
- Subscribing to
"all": trueclears any specific ticker subscriptions for that channel. - Subscribing to specific tickers disables “all” mode for that channel.
- Each channel (
prices,trades, andorderbook) maintains independent subscription state. - You can be subscribed to all prices while only subscribing to specific tickers for trades or orderbooks, or any combination.
Quick Start Example
Best Practices
Connection Management
Implement reconnection logic with exponential backoff to handle
disconnections gracefully.
Subscription Scope
Subscribe only to the markets you need. Use specific tickers rather than
“all” when possible to reduce bandwidth.
Message Handling
Process messages asynchronously to avoid blocking the WebSocket connection
during high-volume periods.
Error Handling
Always implement
onerror and onclose handlers to detect and respond to
connection issues.