Skip to main content
All client messages are JSON text frames with an op field. The multi-events stream accepts three ops: subscribe, unsubscribe and ping.

subscribe

"subscribe"
required
The operation.
string
required
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.
string
required
Always "multi-events". Any other value returns UNKNOWN_CHANNEL.
object
required
What to stream. See Params.
string | object
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.
Put filters inside params. Unknown keys at the top level of the message are silently ignored, so a filters key next to params has no effect and you receive every trade on the chain.

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).
string[]
required
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.
string[]
required
One or more event kinds, each at most once:
  • swap: the trade as indexed and priced.
  • swap-enriched: the same trade plus baseTokenData and quoteTokenData.
See Event payloads.
object
Optional. Either a single filter that applies to every requested event kind, or a map from event kind to filter. Without filters, every trade on the requested chains is delivered.
In the map form, every kind listed in 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.
integer
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>:
produces four pairs: 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 cursor nor cursors.
subscribed is always sent before any event of the subscription, including replayed events.

The event envelope

Every matching trade arrives in an event message:
"event"
Message type.
string
Your subscription id.
"multi-events"
Channel name.
string
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.
string
Position of this trade in the pair’s stream, for example 55410325-0:7. Store it to resume. Left out on sampled subscriptions.
object
The trade. See Event payloads.
Besides events, a subscription can receive cursor checkpoints and gap messages. Both carry pair under the same rule. See Cursors and resuming.

Sampling

Set maxUpdatesPerMinute 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: 60 can deliver up to 240 events a minute.
  • Sampled events have no cursor, subscribed has no cursors, and no cursor checkpoints are sent.
  • A sampled subscription can’t be resumed. Sending since together with maxUpdatesPerMinute fails with INVALID_PARAMETERS: A sampled subscription drops items and cannot resume, subscribe without since or maxUpdatesPerMinute.
  • gap messages are still sent to sampled subscriptions.
Sampling doesn’t change the cost of a subscription.

unsubscribe

The server replies:
The id can then be reused. Unsubscribing an id that isn’t active returns:
Subscriptions don’t survive a disconnect. When the socket closes, all its subscriptions are removed, and you need to subscribe again on the new connection.

ping

The server replies { "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:
  • id is the subscription the error is about. It is missing when the message itself couldn’t be read, for example invalid JSON, an unknown op, or a malformed id or since.
  • For parameter errors, details lists each problem as { field, message }, where field is the dotted path inside params (for example chains.0 or filters.and.0.gte.0), and message joins them as field: message separated by ; . An unknown key in params has an empty field, for example { "field": "", "message": "Unrecognized key: \"filter\"" }.
  • After any subscribe error except DUPLICATE_SUBSCRIPTION, the id is free to use again.
Common subscribe errors: The full list, including connection-level errors, is in Limits and subscription cost.