wss://api.serialized.xyz/v1/stream
One connection, many subscriptions. Subscriptions are additive: each subscribe carries a client-chosen id, acks are explicit, and unsubscribe targets one id without touching the others.
Authentication
Send your key as the first frame within 10 seconds of connecting:{"op":"auth","apiKey":"YOUR_API_KEY"}. The server replies {"op":"auth.ok"}; any other first frame closes the connection (code 4401).
Keepalive
Send{"op":"ping"} every 30s; the server replies {"op":"pong"}. Connections idle for more than 60s are closed.
Errors
Errors arrive as{"op":"error","id":"<sub id>","error":{"code","message"}} - the same machine-readable catalog as REST (INVALID_PARAM, INVALID_CHAIN, …). A bad subscribe only fails that subscription, never the connection.
Connection close codes:
Reconnect & resume
Delivery is at-most-once: after a reconnect, backfill the gap over REST (trades hascursor + fromAt), then re-subscribe. Trade events carry a stable identity key (txHash, block, logIndex) for exact dedup.
Limits
Limits per key, on every plan: 10 concurrent connections, 50 subscriptions per connection, 100 distinct tokens/pools acrosstrades/token-updates/pool-updates (token-updates and pool-updates each take up to 50 subscriptions per key). A connection sending more than 200 frames in 10 seconds is closed (1008). Need more? Ask us.
Billing
Streams bill what you receive, and only that: 1 credit per event delivered, on every channel. The connection itself is free, however long it stays open. A subscription that receives nothing costs nothing. An event held back bymaxUpdatesPerMinute or lost to backpressure (gap) is never billed.
Example: one connection open for an hour, with 5
trades subscriptions that deliver 1,200 trades in total, costs 1,200 credits. GET /v1/usage/breakdown reports each channel under WS <channel>, where requests is the number of events delivered, and connection time under WS /v1/stream at 0 credits.
Bounding the cost of a busy token
Everysubscribe accepts an optional maxUpdatesPerMinute (integer, 1 to 6000): the maximum number of events delivered per minute on that subscription. The first event is delivered immediately; within each window only the most recent event is kept and delivered when the window ends. On trades you then receive the latest trade of each window rather than every trade; on token-updates and pool-updates you receive the latest state, which is all you need. Omit it to receive every event.
Subscribe with a cap of one event per second