WebSocket Connection
Real-time streaming setup and message format
WebSocket Connection
The PRIME WebSocket API provides real-time streaming for market data, order updates, and balance changes.
Connection Details
Connecting
JavaScript Example
Python Example
Important: The subprotocol ws.t-dx.com is required. Connections without it will be rejected.
Message Format
Client Request
*Topic is required for all events except tdx:cancel_on_disconnect
Server Response
Topic Format
Topics follow the format {target}@{category} or {target}@{category}@{parameter}:
See WebSocket Topics Reference for complete topic documentation.
Authentication
Per-Message Authentication
Include the token in each message:
Connection Header
Pass token during connection via HTTP header:
Message-level authentication (a field) overrides connection-level authentication.
Anonymous Access
Public data (trades, depth, prices) is available without authentication. Account-specific data (balances, orders) requires authentication.
Event Types
Client Events
Server Events
Data Events
Quick Examples
Subscribe to Trades
Subscribe to Order Book
Subscribe to Balances (Authenticated)
Error Handling
Connection Management
Rate Limiting
Debouncing
High-frequency updates (prices, balances) are debounced at 500ms intervals.
Keep-Alive
The server sends periodic ping frames. Most WebSocket libraries handle pong responses automatically.
Cancel on Disconnect
Enable automatic order cancellation when disconnected:
Only one cancel-on-disconnect session per client account is allowed.
Reconnection Strategy
Related
- WebSocket Topics Reference - Complete topic documentation with message structures