Skip to content

cmdtyView Desktop API

The cmdtyView Desktop API provides localhost access to cmdtyView market data through two interfaces:

  • WebSocket endpoint for real-time streaming market data
  • HTTP endpoint for historical OHLC data

Instead of connecting directly to Barchart infrastructure, your application connects to localhost, while cmdtyView Desktop handles authentication, permissions, and the upstream connection.

For JavaScript and TypeScript, the cmdtyView Desktop SDK (@barchart/desktop-sdk-js) is the easiest way to connect. It handles login, subscriptions, snapshots, and updates for you, and gives you ready-to-use quotes, order books, and cumulative volume, with prices already scaled and formatted.

This guide walks you through enabling the Desktop API, confirming that the local server is running, and testing both real-time streaming and historical data retrieval.

Setup

  1. Download and install cmdtyView Desktop

    If you haven’t already, download the application from:

    barchart.com/cmdty/trading/cmdtyview/desktop

    The desktop app is required for the localhost proxy to work.

  2. Open the app and log in

    Launch cmdtyView Desktop, log into an account with Desktop API privileges, and keep it running.

    The localhost proxy requires an active session with the appropriate permissions.

  3. Enable the localhost proxy

    Navigate to the Settings menu in cmdtyView Desktop:

    • Click the Settings icon, the gear icon, in the application
    • Go to the Desktop API section
    • Toggle the switch to On to enable the proxy server
  4. Confirm the port

    The default port is 9000. You can change this in the Desktop API settings if needed.

⚠️ Important
If your account does not have Desktop API privileges, the Desktop API section will not appear in Settings and you will not be able to start the local cmdtyView Desktop API. Contact your administrator or Barchart support to request access.

Note
After making any changes to the Desktop API settings, click the Apply button for the changes to take effect.

Health check

Open the health endpoint in your browser or fetch it from your app.

This is a simple HTTP request to verify that the localhost proxy is up and running. The actual data connection to cmdtyView uses WebSocket. See the Live example section below.

http://localhost:9000/health

Expected JSON response:

{
"status": "ok",
"message": "openfeed proxy is running on port: 9000"
}

Note
If you changed the port in Settings, make sure to update the port number in the URL.

Live example

Check the server first, then connect the WebSocket.

Historical Data API

The cmdtyView Desktop API provides an HTTP endpoint for fetching historical OHLC data.

Unlike real-time streaming, which uses WebSocket, historical data is retrieved via a simple HTTP GET request.

Endpoint

GET http://localhost:9000/api/history

Query parameters

Either symbol or expression is required. All other parameters control the data range and aggregation.

ParameterTypeRequiredDescription
symbolstring*The market symbol, for example AAPL or ESM26
expressionstring*Calculated expression, for example {ZC*1}-{ZC*2}
aggregationstring✓Data aggregation: tick, 1m, 5m, 15m, 60m, daily, weekly, monthly, etc.
rangeTypestring✓One of: recordsback, daysback, daterange
recordsnumberif recordsbackNumber of records to return, max 5000
daysnumberif daysbackNumber of days back
startstringif daterangeStart date, for example 2024-01-01
endstringif daterangeEnd date, for example 2024-06-01

* Either symbol or expression is required. At least one must be provided.

Response format

The response is a JSON object containing metadata about the symbol and a columnar data structure with timestamps and field values.

{
"symbol": "AAPL",
"aggregation": "daily",
"metadata": {
"unitCode": "2",
"hasOpenInterest": false
},
"fields": ["open", "high", "low", "close", "volume"],
"data": {
"timestamps": [1716768000000, 1716854400000, 1716940800000],
"open": [189.5, 190.25, 191.0],
"high": [192.0, 193.5, 194.25],
"low": [188.75, 189.5, 190.0],
"close": [191.25, 192.75, 193.5],
"volume": [52000000, 48500000, 55000000]
}
}

Timestamps are in epoch milliseconds, UTC. The fields array lists which data arrays are included in the response.

Example request

// Fetch last 50 daily bars for AAPL
const response = await fetch(
"http://localhost:9000/api/history?symbol=AAPL&aggregation=daily&rangeType=recordsback&records=50",
);
const data = await response.json();
console.log("Records:", data.data.timestamps.length);
console.log("Fields:", data.fields);
// Access the close prices
const closePrices = data.data.close;
console.log("Latest close:", closePrices[closePrices.length - 1]);

Note
For expression symbols containing special characters like {ZC*1}-{ZC*2}, use the expression parameter instead of symbol. The curly brackets will be URL-encoded automatically by your HTTP client.

Historical data demo

SDK Installation

Before using the code snippets below, you’ll need to install an SDK for your programming language. There are two SDKs to choose from, and you can use either one. Both are open source.

cmdtyView Desktop SDK (recommended for JavaScript and TypeScript). The cmdtyView Desktop SDK is the easier, more opinionated way to get market data. You subscribe to a symbol and get ready-to-use quotes, order books, and cumulative volume, with prices already scaled and formatted. The SDK applies snapshots and updates for you, so you never process Openfeed messages yourself. It is open source and available on GitHub.

Openfeed SDKs (lower level). The Openfeed SDKs give you the raw Openfeed messages: instrument definitions, snapshots, and updates. You decide how to process them and keep your own market state. They are open source and available for JavaScript, Python, Go, Java, and C#.

You don’t lose access to raw data by choosing the Desktop SDK. It runs on top of the Openfeed JavaScript client and also has an API for subscribing to raw Openfeed messages, for anything it doesn’t model itself. See Raw market data for both ways to get raw messages in JavaScript.

Note
The Desktop SDK is currently available for JavaScript and TypeScript only. Versions for other languages are in development. Until they are released, use the Openfeed SDK for your language.

On this page, the JavaScript streaming snippet uses the Desktop SDK, and the streaming snippets for other languages use the Openfeed SDKs.

Choose your language and follow the installation steps:

Install via npm:

Terminal window
npm install @barchart/desktop-sdk-js @openfeed/sdk-js long

@openfeed/sdk-js and long are peer dependencies, so your application and the SDK share one Openfeed client.

Snippets

Use these as a starting point for your own integration.

  • Streaming: the JavaScript snippet uses the cmdtyView Desktop SDK. The other languages use their Openfeed SDK. To see raw Openfeed messages in JavaScript instead, see Raw market data.
  • Health check and historical data: these are plain HTTP requests and don’t need an SDK.

Minimal health check

const response = await fetch("http://localhost:9000/health");
const health = await response.json();
console.log("Local proxy health:", health);

Minimal Desktop API connection using the SDK

Sign in with the same username and password that cmdtyView Desktop is signed in with. Other credentials are rejected.

import { DesktopSdk } from "@barchart/desktop-sdk-js";
// Replace with your cmdtyView Desktop API credentials
const wsUrl = "ws://localhost:9000";
const username = "YOUR_USERNAME";
const password = "YOUR_PASSWORD";
const sdk = new DesktopSdk();
sdk.login({ url: wsUrl, username, password });
const symbol = "ESZ26";
sdk.subscribeQuote(symbol, {
onEvent({ kind, instrument, quote, formatted }) {
console.log(kind, instrument.symbol, formatted.session.last, quote.session.volume);
},
onError(error) {
console.error(error.symbol, error.message);
},
});
await sdk.whenConnected();
console.log("Connected to the WebSocket server");

Minimal historical data fetch

const response = await fetch(
"http://localhost:9000/api/history?symbol=ESM26&aggregation=daily&rangeType=recordsback&records=50"
);
const data = await response.json();
console.log(`Fetched ${data.data.timestamps.length} records`);
console.log("Latest close:", data.data.close[data.data.close.length - 1]);

Next steps

After you confirm that the local Desktop API server is running and that you can receive data through the demo, the next step is to build your integration using one of the supported SDKs.

  • JavaScript: see the cmdtyView Desktop SDK README, its reference, and its examples for quotes, order books, cumulative volume, and connection handling.
  • Other languages: the cmdtyView Desktop API uses the same message model and SDK patterns as Openfeed, so the Openfeed SDK documentation covers the implementation details, including message formats, subscriptions, and real-time data handling.