> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# Real-Time Data via WebSocket

Market data streams over a WebSocket on a dedicated host. The low-level wire protocol — frame types, request framing, heartbeats, and market replay — is the same one the trading API uses, so see the Trade API [Real-Time Data via WebSocket](/api/websockets) guide for the full protocol. This page covers what's specific to market data.

## Connect and Authorize

Open a WebSocket to the market-data host and authorize it once with your `mdAccessToken` (see [Authentication & Access](/market-data/authentication)):

```text
wss://md-demo.tradovateapi.com/v1/websocket
```

## Subscribe and Stream

Send a subscription request — for example `md/subscribeQuote` with a `symbol` — and the server streams matching events until you unsubscribe. Each subscription returns a subscription ID; cache it so you can unsubscribe later. The **WebSocket API** reference documents every channel and message, and the [Market Data overview](/market-data) walks the end-to-end flow.

## Market Data Events

Market data arrives as event frames inside `a[...]` array frames:

* **`e: "md"`** — quote, DOM, and histogram updates, carried in `d.quotes`, `d.doms`, or `d.histograms`.
* **`e: "chart"`** — bar and tick chart packets, carried in `d.charts`.

For example, a quote event:

```js
{
  "e": "md",
  "d": {
    "quotes": [
      {
        "timestamp": "2021-04-13T04:59:06.588Z",
        "contractId": 123456,
        "entries": {
          "Bid": { "price": 4205.25, "size": 12 },
          "Offer": { "price": 4205.50, "size": 8 },
          "Trade": { "price": 4205.25, "size": 3 }
        }
      }
    ]
  }
}
```

A server that's actively streaming won't send heartbeats, so your client must send a heartbeat every 2.5 seconds to keep the connection alive. See [Client Heartbeats](/api/websockets#client-heartbeats) in the protocol guide.