WebSocket API
Tracera provides real-time price and volatility updates over a persistent WebSocket connection.For details on the real-time delivery architecture, see Data Flow and Real-Time Features.
Connection
GET /api/v1/ws
Establish a WebSocket connection for live updates.Origin Validation
WebSocket upgrade requests are validated against the configuredBASE_URL origin. In development, loopback origins (localhost, 127.0.0.1) are also accepted.
Subscribing to Items
After connecting, send a subscription message to receive updates for specific items:Subscription Limits
- Item IDs are bounded to a maximum count per client
- IDs are deduplicated — sending the same ID twice has no effect
- Only positive integers are accepted — invalid IDs are filtered out
Message Types
Price Update
Received when a tracked item’s price changes:Volatility Update
Received when volatility metrics are recomputed:Architecture
- Subscribes to Redis Pub/Sub channels for price and volatility updates
- Maintains a registry of connected clients and their subscriptions
- Fans out updates to only the clients subscribed to the relevant item IDs
- Handles client disconnections and subscription changes