Market Data
The Market Data API provides access to market data such as quotes, DOM, charts, and histograms. It uses JSON for request bodies and response data, exchanged over the WebSocket protocol.
Example projects are available in C# and JavaScript.
Subscribing to Market Data
A typical market data scenario follows these steps:
-
Acquire an access token. Use the standard authentication procedure.
-
Open a WebSocket and authorize it. Open a connection and send your access token using the WebSocket authorization procedure.
-
Build a request. Request parameters are a JSON object. Every real-time request requires a
symbolparameter identifying the contract — either the contract symbol string or the contract ID integer: -
Subscribe. Send the request to the server, specifying an endpoint such as
md/subscribeQuote. The server replies with a response message. On success, the subscription is activated and you begin receiving data; on error, perform error handling. A client can hold a single subscription of each type (quotes, DOM, or charts) per contract, so it’s your responsibility to track the contracts you’ve subscribed to in order to unsubscribe later.
Handling Market Data
Market data arrives asynchronously as event messages of type md or chart. For example:
Unsubscribing from Market Data
To unsubscribe, build request parameters as you did to subscribe, specify the matching unsubscribe endpoint such as md/unsubscribeQuote, and send it. On success, the server deactivates the subscription and stops sending real-time data.
Request Reference
Subscribe Quote
Endpoint: md/subscribeQuote
Parameters:
Data message:
Unsubscribe Quote
Endpoint: md/unsubscribeQuote
Parameters:
Subscribe DOM
Endpoint: md/subscribeDOM
Parameters:
Data message:
Unsubscribe DOM
Endpoint: md/unsubscribeDOM
Parameters:
Subscribe Histogram
Endpoint: md/subscribeHistogram
Parameters:
Data message:
Unsubscribe Histogram
Endpoint: md/unsubscribeHistogram
Parameters:
Get Chart
A client may hold multiple charts for the same contract, so the response to md/getChart contains subscription IDs you use to track and unsubscribe from a real-time chart.
Endpoint: md/getChart
Parameters:
Response: The response contains two subscription IDs, historicalId and realtimeId. Store realtimeId so you can cancel the real-time chart subscription with md/cancelChart.
Data message:
Cancel Chart
Endpoint: md/cancelChart
Parameters:

