> 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.

# Getting Started

This guide walks you through connecting to the Market Data API and subscribing to your first real-time quote. Market data streams over a dedicated WebSocket connection, separate from the trading API.

## What You Need

* **An access token.** Market data uses the same credentials as the Trade API. If you don't have a token yet, follow the Trade API [Getting Started](/api/getting-started) guide first. The token response includes an `mdAccessToken` field specifically for market data connections.
* **A WebSocket client.** Any library that supports the `wss://` protocol works. Most languages and frameworks include one.

All examples on this page use the Demo environment. Swap in `wss://md.tradovateapi.com/v1/websocket` for Live market data.

#### Connect to the WebSocket

Open a WebSocket connection to the market data Demo host:

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

When the connection opens, the server sends an `o` (open) frame to confirm the session is established. After that, it sends `h` (heartbeat) frames about every 2.5 seconds. Your client must reply to each heartbeat with `[]` to keep the connection alive.

#### Authorize the connection

Send an `authorize` request with the `mdAccessToken` from your [token response](/api/authentication#access-tokens). The WebSocket text protocol separates the endpoint name, a request ID, and the body with newlines:

```text
authorize
1

<your mdAccessToken>
```

A successful response returns status `200`:

```text
a[{"s":200,"i":1}]
```

You only need to authorize once per connection. For the full authorization flow and server details, see [Authentication & Access](/market-data/authentication).

#### Subscribe to a quote

Send an `md/subscribeQuote` request with the contract symbol you want to track:

```text
md/subscribeQuote
2

{"symbol":"ESM7"}
```

On success, the server begins streaming quote events as they occur. Each event arrives as an `a` frame with event type `md`:

```json
{
  "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 },
          "TotalTradeVolume": { "size": 841200 }
        }
      }
    ]
  }
}
```

The `entries` object contains the available data points for that contract. Common entry types include `Bid`, `Offer`, `Trade`, `HighPrice`, `LowPrice`, `OpeningPrice`, and `TotalTradeVolume`.

To stop receiving updates for a contract, send `md/unsubscribeQuote` with the same symbol. You can hold one subscription per type (quotes, DOM, charts) per contract, so track your active subscriptions to clean them up later.

## Next Steps

* Read [Real-Time Data via WebSocket](/market-data/websockets) for the full protocol, including DOM, chart, and histogram subscriptions.
* Browse the [WebSocket API](/market-data/websocket-api) reference for every available channel and message format.
* See [Tick Charts](/market-data/tick-charts) for tick-level chart data.