Connection
Connect to the WebSocket server:Protocol
The Notional WebSocket API uses JSON messages for bidirectional communication:- Client → Server: Subscribe, unsubscribe, ping
- Server → Client: Data updates, confirmations, errors
Quick Start
Subscription Types
User-Specific Subscriptions
Require auser parameter (your wallet address in lowercase):
User Fills
Real-time trade execution notifications
Account Summary
Live account balance, positions, and margin
Order Updates
Order status changes (pending/open/filled/canceled)
Order Rejections
Order rejection notifications with error codes
User Transactions
All transactions involving your account
Global Subscriptions
Nouser parameter needed - available to all clients:
Message Format
Subscribe
Unsubscribe
Ping
Server Messages
Data Update:Multiple Subscriptions
Subscribe to multiple channels over a single connection:Connection Management
Heartbeat
Send pings every 30 seconds to keep the connection alive:Idle Timeout
- Connections idle for 60 seconds are automatically closed
- Send pings every 30 seconds to prevent timeout
Reconnection
If the connection drops:- Exponential Backoff: Wait before reconnecting (1s, 2s, 4s, etc.)
- Resubscribe: Re-establish all subscriptions after reconnect
- Sync State: Fetch latest data via REST API if needed
Compression
Per-message deflate compression is enabled by default for bandwidth efficiency.Error Handling
Common error messages:Best Practices
Address Format
- Always use lowercase addresses:
0x742d...not0x742D...
Message Handling
- Parse messages in try-catch blocks
- Check
channelfield in every message - Handle errors gracefully
Connection Management
- Subscribe after
onopenevent fires - Resubscribe on reconnection
- Send pings every 30 seconds
- Unsubscribe before closing connection
Performance
- Share WebSocket connections across subscriptions
- Filter client-side for high-volume streams
- Batch UI updates to avoid render overload
- Consider rate limiting for global subscriptions
Connection Limits
- Max Payload: 16 KB per message
- Idle Timeout: 60 seconds
- Max Connections: Unlimited (subject to fair use)
Status Monitoring
Check WebSocket server health:fillsPoller status to verify data availability.