# Multi Market Data (Archived)

:::warning
This documentation is archived for reference only. These APIs have been replaced by the [**new WebSocket API**](/websocket/introduction). **Start new integrations with the new WebSocket API.**
:::

# Multi Market Data

Multi market data is a public API which allows multiple symbols to be streamed via a single endpoint.

## WebSocket Request

`wss://api.gemini.com/v1/multimarketdata?symbols=BTCUSD,ETHUSD`

## URL Parameters

| Parameter | Required | Default | Description |
| --------- | -------- | ------- | ----------- |
| `symbols` | Yes | - | Symbols to stream (comma-separated) |
| `heartbeat` | No | false | Set to `true` for heartbeats every 5 seconds |
| `top_of_book` | No | false | If `true`, receive top of book only |
| `bids` | No | true | Include bids in `change` events |
| `offers` | No | true | Include asks in `change` events |
| `trades` | No | true | Include `trade` events |

## Response

| Field | Type | Description |
| ----- | ---- | ----------- |
| `type` | string | `heartbeat` or `update` |
| `socket_sequence` | integer | Monotonic increasing sequence number |

Messages of type `update` also include:

| Field | Type | Description |
| ----- | ---- | ----------- |
| `eventId` | integer | Monotonically increasing sequence number |
| `events` | array | Order book changes or trade indications |
| `timestamp` | timestamp | Timestamp in seconds |
| `timestampms` | timestampms | Timestamp in milliseconds |

All elements of `events` share:

| Field | Type | Description |
| ----- | ---- | ----------- |
| `type` | string | `trade` or `change` |
| `symbol` | string | Symbol (e.g. `BTCUSD`, `ETHUSD`) |

### Change Event

| Field | Type | Description |
| ----- | ---- | ----------- |
| `price` | decimal | Price of this order book entry |
| `side` | string | `bid` or `ask` |
| `reason` | string | `place`, `trade`, `cancel`, or `initial` |
| `remaining` | decimal | Quantity remaining at this price level |
| `delta` | decimal | Quantity changed |

### Trade Event

| Field | Type | Description |
| ----- | ---- | ----------- |
| `price` | decimal | Execution price |
| `amount` | decimal | Amount traded |
| `makerSide` | string | `bid` or `ask` |

## Examples

```python
import ssl
import websocket

def on_message(ws, message):
    print(message)

ws = websocket.WebSocketApp(
    "wss://api.gemini.com/v1/multimarketdata?symbols=BTCUSD,ETHUSD",
    on_message=on_message)
ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
```

### Trade Event

```json
{
  "type": "update",
  "eventId": 5375547515,
  "timestamp": 1547760288,
  "timestampms": 1547760288001,
  "socket_sequence": 15,
  "events": [
    {
      "type": "trade",
      "tid": 5375547515,
      "price": "3632.54",
      "amount": "0.1362819142",
      "makerSide": "ask",
      "symbol": "BTCUSD"
    }
  ]
}
```
