WebSockets provide a persistent connection between your application and Pragma’s servers, allowing for real-time data streaming with minimal latency.
Connection Endpoints
- Development
- Production
Authentication
All WebSocket connections are currently public and open without authentication.
Connection Management
Connection Lifecycle
Understanding how to properly establish, maintain, and close WebSocket connections is essential for reliable real-time data streaming.
Reconnection Strategy
Implement proper reconnection logic to handle network interruptions and server-initiated disconnects gracefully.
Supported Assets
The WebSocket API currently supports streaming prices for the following pairs:Crypto
BTC/USDETH/USDSOL/USDSTRK/USDUSDC/USDUSDT/USD
FX
EUR/USDEUR/USDWUSD/JPYUSD/JPYW
Metals
XAU/USDXAG/USDXPL/USD
Indices
SPX500M/USDTECH100M/USD
Energy
XBR/USD
Connection Limits
Byte Rate Limiting
Byte Rate Limiting
256
KB per second limit
Each IP address is limited to 256 KB per second of data transmission
Connections exceeding this limit are automatically closed without warning
Rate limits are tracked and enforced per unique IP address. Consider this when deploying multiple applications or services from the same origin.
Inactivity Timeouts
Inactivity Timeouts
60s
Inactivity timeout
Connections automatically close after 60 seconds of inactivity
Recommended Practice
Send a ping message every 30 seconds to keep the connection alive
This timeout prevents resource consumption from idle connections and ensures efficient server utilization.
Best Practices
Implement proper error handling
Always include robust error handling and reconnection logic in your WebSocket implementation. Network disconnections and server-side issues can occur, and your application should gracefully recover from these scenarios.
Use ping/pong messages
Send regular ping messages (every 30 seconds) to keep the connection alive and detect stale connections early.
Monitor connection health
Track connection state and performance metrics in your application to ensure reliable data delivery and prompt detection of issues.
Common Issues & Troubleshooting
Connection Closed Unexpectedly
Connection Closed Unexpectedly
Possible causes:
- Rate limit exceeded (256 KB/s)
- Inactivity timeout (60 seconds without messages)
- Server maintenance or restarts
Message Format Errors
Message Format Errors
Possible causes:
- Incorrectly formatted JSON messages
- Missing required fields
- Invalid subscription parameters
High Latency
High Latency
Possible causes:
- Network congestion
- Geographic distance from server
- Client-side processing delays