Getting Started

Get access, authorize the WebSocket, and receive your first quote.
View as Markdown

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

1

Connect to the WebSocket

Open a WebSocket connection to the market data Demo host:

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.

2

Authorize the connection

Send an authorize request with the mdAccessToken from your token response. The WebSocket text protocol separates the endpoint name, a request ID, and the body with newlines:

authorize
1
<your mdAccessToken>

A successful response returns status 200:

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

You only need to authorize once per connection. For the full authorization flow and server details, see Authentication & Access.

3

Subscribe to a quote

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

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:

1{
2 "e": "md",
3 "d": {
4 "quotes": [
5 {
6 "timestamp": "2021-04-13T04:59:06.588Z",
7 "contractId": 123456,
8 "entries": {
9 "Bid": { "price": 4205.25, "size": 12 },
10 "Offer": { "price": 4205.50, "size": 8 },
11 "Trade": { "price": 4205.25, "size": 3 },
12 "TotalTradeVolume": { "size": 841200 }
13 }
14 }
15 ]
16 }
17}

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