WebSocket API
The WebSocket API provides real-time streaming data for market information and private user data.Endpoints
| Endpoint | Description | Authentication |
|---|---|---|
/v1/ws/private | Orders, positions, account balance updates | API Key |
/v1/ws/markets | Market data, order book, trades | API Key |
Connection
Connect to the WebSocket endpoints with your API key credentials:Authentication
WebSocket connections use the same authentication headers as the REST API:Message Format
All WebSocket messages are JSON formatted with snake_case field names.Request Format
Subscription Types
Private WebSocket (/v1/ws/private):
| Value | Type | Description |
|---|---|---|
| 1 | ORDER | Order updates |
| 3 | POSITION | Position changes |
| 4 | ACCOUNT_BALANCE | Balance updates |
/v1/ws/markets):
| Value | Type | Description |
|---|---|---|
| 1 | MARKET_DATA | Full order book and market stats |
| 2 | MARKET_DATA_LITE | Lightweight price data |
| 3 | TRADE | Real-time trade notifications |
Response Format
Heartbeats
The server sends periodic heartbeat messages to keep the connection alive:Error Handling
If a subscription request fails, the response will include an error field:Unsubscribing
To unsubscribe from a stream:Best Practices
- Use unique request IDs - Track subscriptions with unique identifiers
- Handle reconnection - Implement automatic reconnection with exponential backoff
- Process messages in order - Messages are delivered in sequence
- Monitor heartbeats - Reconnect if heartbeats stop
- Limit subscriptions - Only subscribe to markets you need