> ## Documentation Index
> Fetch the complete documentation index at: https://docs.serialized.trade/llms.txt
> Use this file to discover all available pages before exploring further.

# Streams overview

> Real-time push over a single WebSocket connection: live trades, candles, token updates and token filter views. Event payloads reuse the exact same shapes as their REST twins - anything you built against REST parses stream events unchanged.

Real-time push over a single WebSocket connection: live trades, candles, token updates and token filter views. Event payloads reuse the exact same shapes as their REST twins - anything you built against REST parses stream events unchanged.

**Endpoint** : `wss://api.serialized.trade/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.

## Reconnect & resume

Delivery is at-most-once: after a reconnect, backfill the gap over REST (trades has `cursor` + `fromAt`, candles have `endTime`), then re-subscribe. Trade events carry a stable identity key (`txHash`, `block`, `logIndex`) for exact dedup.

## Limits

Limits per key: 5 concurrent connections, 20 subscriptions per connection, 50 distinct tokens/pools across `trades`/`ohlcv`/`token-updates`. Need more? Ask us.

## Billing

Streams bill connection time: 1 credit per connection-minute, with no per-message cost.

## Connection walkthrough

<CodeGroup>
  ```json Auth (first frame) theme={null}
  {
    "op": "auth",
    "apiKey": "YOUR_API_KEY"
  }
  ```

  ```json Auth ok theme={null}
  {
    "op": "auth.ok"
  }
  ```

  ```json Subscribe theme={null}
  {
    "op": "subscribe",
    "channel": "trades",
    "id": "tape-1",
    "params": {
      "chain": "evm:8453",
      "address": "0xb2000000000000000000007bf6d5cbb0e24cb301"
    }
  }
  ```

  ```json Ack theme={null}
  {
    "op": "subscribed",
    "id": "tape-1",
    "channel": "trades"
  }
  ```
</CodeGroup>
