Real-time Substreams WebSocket streaming

    Substreams WebSocketBeta

    Stream decoded blocks, swaps, transfers, and any Substreams DatabaseChanges output in real time. Subscribe to one channel or many across SVM, EVM, and TVM with the same URL pattern — and resume where you left off after a disconnect.

    WSSUBSCRIBE#

    Add channels to the per-connection subscription set. Idempotent. Wildcards (*@swaps, solana@*) are accepted.

    Request

    { "method": "SUBSCRIBE",
      "params": ["solana@swaps", "mainnet@erc20_transfers"],
      "id": 1 }

    Reply

    { "result": null, "id": 1 }

    A single bad selector rejects the whole command — the existing set is unchanged. The wrap_envelope mode is fixed at upgrade time and is not affected by SUBSCRIBE.

    WSUNSUBSCRIBE#

    Remove channels from the subscription set. Silently ignores unknown selectors.

    { "method": "UNSUBSCRIBE",
      "params": ["mainnet@erc20_transfers"],
      "id": 2 }

    To remove a wildcard subscription pass the exact wildcard form — *@swaps removes the wildcard entry, not the individual streams it currently matches.

    WSLIST_SUBSCRIPTIONS#

    Inspect the current subscription set. Order preserved, wildcards returned verbatim.

    { "method": "LIST_SUBSCRIPTIONS", "id": 3 }
    // →
    { "result": ["solana@swaps", "mainnet@*"], "id": 3 }

    WSSET_FILTER#

    Drop non-matching events from the wire before delivery. String equality only; fields AND; values OR; missing-field counts as a miss. Filters apply per explicit network@stream selector — wildcards always pass through.

    { "method": "SET_FILTER",
      "params": [
        "solana@swaps",
        { "protocol": "raydium_cpmm", "user": ["a", "b"] }
      ],
      "id": 1 }
    Limits. Max 16 keys per filter, 64 total values. Top-level fields (block_num, network, module_hash) are not filterable — only keys inside events[*].

    WSCLEAR_FILTER#

    Drop the filter for the listed selectors. Silently ignores selectors without a filter.

    { "method": "CLEAR_FILTER", "params": ["solana@swaps"], "id": 2 }