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

# WebSocket command schemas

> JSON Schema for every 0xArchive WebSocket command, with required and optional fields, and the names of the events the server sends back.

Validate each command your client sends against its JSON Schema below. Event payloads differ by channel, so this page lists events by name; [Protocol reference](/websocket/schema#server-events) describes each event and the channel pages describe their payloads.

## Commands

| Command | Fields |
| - | - |
| `subscribe` | Required: `op`, `channel`, `symbol` (except on `all_tickers` and `mempool`)<br />Optional: `interval_ms` |
| `unsubscribe` | Required: `op`, `channel`, `symbol` (except on `all_tickers` and `mempool`) |
| `replay` | Required: `op`, `channel` or `channels`, `symbol`, `start`<br />Optional: `end`, `speed`, `interval` |
| `replay.pause` | Required: `op` |
| `replay.resume` | Required: `op` |
| `replay.seek` | Required: `op`, `timestamp` |
| `replay.stop` | Required: `op` |
| `ping` | Required: `op` |

Send exactly one of `channel` or `channels` in a `replay`. `symbol` is required on every channel except `all_tickers`, which takes none, and `mempool`, where it is optional.

## Events

The server sends these events: `subscribed`, `unsubscribed`, `pong`, `data`, `l4_snapshot`, `l4_batch`, `replay_started`, `replay_snapshot`, `historical_data`, `historical_tick_data`, `replay_paused`, `replay_resumed`, `replay_completed`, `replay_stopped`, `gap_detected`, `error`.

## `subscribe` command

```json theme={"theme":"github-dark"}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "subscribe command",
  "type": "object",
  "required": [
    "op",
    "channel"
  ],
  "properties": {
    "op": {
      "const": "subscribe"
    },
    "channel": {
      "type": "string"
    },
    "symbol": {
      "type": "string"
    },
    "interval_ms": {
      "type": "integer",
      "minimum": 100,
      "maximum": 5000,
      "description": "lighter_orderbook and rh_lighter_orderbook only"
    }
  },
  "additionalProperties": true,
  "if": {
    "properties": {
      "channel": {
        "enum": [
          "all_tickers",
          "mempool"
        ]
      }
    }
  },
  "else": {
    "required": [
      "symbol"
    ]
  }
}
```

## `unsubscribe` command

```json theme={"theme":"github-dark"}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "unsubscribe command",
  "type": "object",
  "required": [
    "op",
    "channel"
  ],
  "properties": {
    "op": {
      "const": "unsubscribe"
    },
    "channel": {
      "type": "string"
    },
    "symbol": {
      "type": "string"
    }
  },
  "additionalProperties": true,
  "if": {
    "properties": {
      "channel": {
        "enum": [
          "all_tickers",
          "mempool"
        ]
      }
    }
  },
  "else": {
    "required": [
      "symbol"
    ]
  }
}
```

## `replay` command

```json theme={"theme":"github-dark"}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "replay command",
  "type": "object",
  "required": [
    "op",
    "symbol",
    "start"
  ],
  "properties": {
    "op": {
      "const": "replay"
    },
    "channel": {
      "type": "string"
    },
    "channels": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1
    },
    "symbol": {
      "type": "string"
    },
    "start": {
      "type": [
        "integer",
        "string"
      ],
      "description": "Unix milliseconds, or an RFC 3339 string"
    },
    "end": {
      "type": [
        "integer",
        "string"
      ],
      "description": "Unix milliseconds, or an RFC 3339 string"
    },
    "speed": {
      "type": "number",
      "exclusiveMinimum": 0,
      "description": "Standard timed replay only; capped at the plan standard replay speed"
    },
    "interval": {
      "enum": [
        "1m",
        "5m",
        "15m",
        "30m",
        "1h",
        "4h",
        "1d",
        "1w"
      ],
      "description": "Candle channels only; defaults to 1h"
    }
  },
  "additionalProperties": true,
  "oneOf": [
    {
      "required": [
        "channel"
      ]
    },
    {
      "required": [
        "channels"
      ]
    }
  ]
}
```

## `replay.pause` command

```json theme={"theme":"github-dark"}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "replay.pause command",
  "type": "object",
  "required": [
    "op"
  ],
  "properties": {
    "op": {
      "const": "replay.pause"
    }
  },
  "additionalProperties": true
}
```

## `replay.resume` command

```json theme={"theme":"github-dark"}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "replay.resume command",
  "type": "object",
  "required": [
    "op"
  ],
  "properties": {
    "op": {
      "const": "replay.resume"
    }
  },
  "additionalProperties": true
}
```

## `replay.seek` command

```json theme={"theme":"github-dark"}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "replay.seek command",
  "type": "object",
  "required": [
    "op",
    "timestamp"
  ],
  "properties": {
    "op": {
      "const": "replay.seek"
    },
    "timestamp": {
      "type": [
        "integer",
        "string"
      ],
      "description": "Unix milliseconds, or an RFC 3339 string"
    }
  },
  "additionalProperties": true
}
```

## `replay.stop` command

```json theme={"theme":"github-dark"}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "replay.stop command",
  "type": "object",
  "required": [
    "op"
  ],
  "properties": {
    "op": {
      "const": "replay.stop"
    }
  },
  "additionalProperties": true
}
```

## `ping` command

```json theme={"theme":"github-dark"}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "ping command",
  "type": "object",
  "required": [
    "op"
  ],
  "properties": {
    "op": {
      "const": "ping"
    }
  },
  "additionalProperties": true
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.