op field. The multi-events stream accepts three ops: subscribe, unsubscribe and ping.
subscribe
A subscription id you choose: 1 to 64 characters made of letters, digits,
_, ., : and -. It must be unique among the active subscriptions on this connection. Every message about this subscription carries the same id.What to stream. See Params.
Optional resume position: a cursor string when the subscription has one pair, or an object mapping pairs to cursors when it has several. See Cursors and resuming.
Params
params is a strict object: any key other than the four below is rejected with INVALID_PARAMETERS (for example a misspelled filter or chain).
One or more chain identifiers in the form
evm:<chainId>, for example "evm:1" or "evm:8453". Each chain may appear only once. Bare numbers and chain names are rejected with the message Invalid blockchain ID. Expected format: "evm:<chainId>" (e.g. "evm:1", "evm:137"). See Chains.One or more event kinds, each at most once:
swap: the trade as indexed and priced.swap-enriched: the same trade plusbaseTokenDataandquoteTokenData.
Optional. Either a single filter that applies to every requested event kind, or a map from event kind to filter. Without In the map form, every kind listed in
filters, every trade on the requested chains is delivered.events needs an entry (filters.<kind>: every requested event needs a filter), and a key that is not in events is rejected (filters.<key>: not in events). You can’t leave one kind unfiltered in a map; use two subscriptions instead. See Filters.Optional, 1 to 600. Turns the subscription into a sampled one that drops events. See Sampling.
Pairs
The server splits a subscription into pairs, one per chain and event kind. A pair is named<event>|<chain>:
swap|evm:1, swap-enriched|evm:1, swap|evm:8453 and swap-enriched|evm:8453.
Each pair has its own cursor and its own cost. Within a pair, events arrive in block order, then in the order of the trades in the block. There is no ordering between pairs.
The subscribed reply
When the subscription is accepted, the server replies with subscribed. Its shape depends on the number of pairs.
- For a pair that starts live, the cursor is the current head of that chain’s stream. It can be
"0-0"if the chain has no data yet. - For a pair you resume with
since, it echoes the cursor you sent. - Sampled subscriptions get neither
cursornorcursors.
subscribed is always sent before any event of the subscription, including replayed events.
The event envelope
Every matching trade arrives in anevent message:
The pair this event belongs to, for example
swap|evm:8453. Present only when the subscription has more than one pair. With a single pair, it is left out.Position of this trade in the pair’s stream, for example
55410325-0:7. Store it to resume. Left out on sampled subscriptions.The trade. See Event payloads.
cursor checkpoints and gap messages. Both carry pair under the same rule. See Cursors and resuming.
Sampling
SetmaxUpdatesPerMinute to cap how often events are sent, for example for a live ticker that doesn’t need every trade.
- The server keeps a minimum interval of
ceil(60000 / maxUpdatesPerMinute)milliseconds between events. A matching trade that arrives before the interval has passed is dropped, not queued. In practice you get the first matching trade after each interval. - The cap applies per pair, not per subscription. A subscription with 2 chains and 2 event kinds at
maxUpdatesPerMinute: 60can deliver up to 240 events a minute. - Sampled events have no
cursor,subscribedhas no cursors, and nocursorcheckpoints are sent. - A sampled subscription can’t be resumed. Sending
sincetogether withmaxUpdatesPerMinutefails withINVALID_PARAMETERS:A sampled subscription drops items and cannot resume, subscribe without since or maxUpdatesPerMinute. gapmessages are still sent to sampled subscriptions.
unsubscribe
ping
{ "type": "pong" }. Use it to measure round-trip time. It is separate from the WebSocket protocol heartbeat: an application ping doesn’t keep the connection alive, and it counts toward the message rate limit.
Errors
Errors use this shape:idis the subscription the error is about. It is missing when the message itself couldn’t be read, for example invalid JSON, an unknownop, or a malformedidorsince.- For parameter errors,
detailslists each problem as{ field, message }, wherefieldis the dotted path insideparams(for examplechains.0orfilters.and.0.gte.0), andmessagejoins them asfield: messageseparated by;. An unknown key inparamshas an emptyfield, for example{ "field": "", "message": "Unrecognized key: \"filter\"" }. - After any subscribe error except
DUPLICATE_SUBSCRIPTION, the id is free to use again.
The full list, including connection-level errors, is in Limits and subscription cost.