Endpoint
- No authentication is needed. Open the socket and start subscribing.
- All frames are JSON text, in both directions. A binary frame or invalid JSON gets a
BAD_REQUESTerror, and the connection stays open.
The Pulse stream (
/v1/ws/pulse) and the multi-events stream (/streams/v1/ws) are separate endpoints with their own protocols. This section covers /v1/ws only.The welcome message
The server sends awelcome message as soon as the connection opens:
Channels
Every channel is fed by the same ordered stream of trades for one chain. Eachevent is produced by one trade. The channels differ in how a trade is selected and what is sent for it.
Only swaps classified as trades are streamed. Liquidity adds and removals, MEV swaps and other non-trade swaps are left out.
WebSocket or REST?
- Use REST for anything historical or one-off: token and market snapshots, candle history, past trades. See the REST API overview.
- Use WebSocket to keep that data up to date afterwards. A common pattern is to load history from REST, then subscribe and apply live events on top. For example, load candles from
GET /token/ohlcv, then follow theohlcvchannel. - The WebSocket API keeps only about 10 minutes of history for resuming (see Cursors and resuming). It does not replace the REST history endpoints.
Chain identifiers
On the WebSocket API,chain must be a string in the form evm:<chainId>, for example "evm:1" or "evm:8453". A bare number such as "8453" or 8453 is rejected:
End-to-end example
This example subscribes to every trade of one token on Base and prints each one.-> is sent by you, <- by the server, event data shortened):
id you choose is echoed on every message for that subscription, so you can route events when several subscriptions share one connection.
Heartbeats
EveryheartbeatMs (30 s by default) the server sends a WebSocket protocol ping frame. If it did not receive a pong since the previous ping, it drops the connection without a close frame, and your client sees close code 1006.
- Browsers, Node
wsand Pythonwebsocketsanswer protocol pings automatically. You don’t need to do anything. - If you turned automatic pongs off in your client library, you must answer pings yourself.
- The application-level
{"op":"ping"}message is optional. It returns{"type":"pong"}and is useful for measuring round-trip time, but it does not count as a heartbeat answer. It also counts toward the message rate limit.
Reconnecting
Subscriptions belong to a connection. When the connection closes for any reason, all its subscriptions are removed, and you must subscribe again on the new connection. To continue without missing trades, store the latest cursor of each subscription and pass it assince when you resubscribe. See Cursors and resuming for the full reconnect loop.
Next steps
Message reference
Every client op and server message type, with fields.
Cursors and resuming
Resume after a disconnect without gaps or duplicates.
Limits and errors
Message limits, close codes and error codes.
fast-trade channel
Start with the simplest channel.