WebSocket Streaming
Connect to the WebSocket for real-time Polymarket trade data.Connection
Subscribe to Channels
All trades
Trades for a specific token
Market resolutions
Unsubscribe
Events
Trade event
Resolution event
Compression
Add?compress=zlib to the connection URL. When enabled:
- All outbound messages are sent as binary frames compressed with deflate (zlib raw)
- Decompress with any standard zlib/inflate implementation
- Saves ~60% bandwidth — recommended for production
Ping / Pong
Send a ping to keep the connection alive:Reconnection
If the connection drops, reconnect with exponential backoff:- Wait 1 second, reconnect
- If it fails, wait 2 seconds
- Double the wait each time, up to 60 seconds max
- On success, re-subscribe to your channels
Best Practices
- Use compression in production
- Subscribe only to channels you need
- Implement reconnection with backoff
- Send pings every 30 seconds to detect dead connections
- Process messages asynchronously to avoid blocking the receive loop