Endpoint
Why use WebSocket over polling?
The REST target endpoints have a ~1–5s publish lag at window boundaries while Chainlink/Binance finalise the price. If you poll right as a new window opens you get a502. The WebSocket absorbs that wait server-side and pushes the price to you the instant it resolves — with no rate limits.
Connection flow
1. Connect
On connect the server immediately sends aconnected event:
2. Subscribe
Send a JSON message to subscribe to one asset across one or more intervals:| Field | Type | Description |
|---|---|---|
type | "subscribe" | Required. |
asset | string | One of the supported asset symbols. |
marketTypes | string[] | One or more interval types. Omit to subscribe to all five. |
subscribed event and immediately sends a window_open snapshot for the current window of each subscribed interval — so you’re never blind while waiting for the next boundary.
3. Receive price events
At every window boundary the server pushes awindow_open event for each subscribed asset + interval:
"snapshot": true.
If the upstream fetch fails after 6 retries, you receive window_open_error instead:
4. Unsubscribe
Heartbeat
The server sends a WebSocket ping every 30 seconds. If your client does not respond with a pong the connection is terminated. Most WebSocket client libraries handle this automatically.Example — Node.js
Example — Browser
Event reference
| Event | Direction | Description |
|---|---|---|
connected | Server → Client | Sent immediately on connect. |
subscribed | Server → Client | Confirms a successful subscribe. |
unsubscribed | Server → Client | Confirms unsubscribe. |
window_open | Server → Client | Price pushed at every window boundary. Also sent as a snapshot on subscribe. |
window_open_error | Server → Client | Sent when the upstream price fetch fails after all retries. |
error | Server → Client | Invalid JSON, unknown asset, or unknown message type. |
subscribe | Client → Server | Subscribe to asset + intervals. |
unsubscribe | Client → Server | Remove all subscriptions. |