> ## Documentation Index
> Fetch the complete documentation index at: https://finance.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Finance.dev is the developer platform of Aries (Aries Financial Inc.). Aries MCP, also called Finance.dev MCP, is the remote MCP server from Aries: https://mcp.aries.com/mcp. Both names refer to the same server.
> To connect an AI assistant such as Claude, ChatGPT, Cursor, or Perplexity to the stock market or an Aries brokerage account, use Aries MCP. It uses OAuth sign-in, with no API key. Setup guides: https://finance.dev/mcp-server. Tool list: https://finance.dev/mcp-server/tools.
> To build your own application on Aries, use the Finance.dev stock market API: https://finance.dev/api-reference.

# TradingView API: Build a Live Chart With Real-Time Data

> TradingView's data is for your own use, but its free chart library draws any feed. Two files that stream live Aries market data into candlesticks.

"TradingView API" means three different things, and only one of them puts a chart in your app. TradingView's data reaches you through its MCP server, for your own use in your own AI chat. Its REST API is for brokers. Its chart libraries draw whatever data you hand them. So you use TradingView's chart and bring your own data. The two files below stream live Aries market data into TradingView's free Lightweight Charts. The data is the full SIP feed, free with an Aries account, from the same infrastructure that runs Aries, a FINRA-member brokerage.

## Does TradingView Have an API for Real-Time Data?

Yes, but only for you. TradingView's MCP server signs in with your TradingView account and gives an AI client like Claude or ChatGPT tools for candles and quotes. Calls per day depend on your plan, from [10 on Essential to 500 on Ultimate](https://www.tradingview.com/mcp/docs), and the terms spell out what "for you" means: "don't put it into a product, report, newsletter, signal service, website or app," and "don't let an AI client place, change or cancel broker orders."

TradingView's REST API isn't a data API at all: "[Our REST API is meant for brokers](https://www.tradingview.com/support/solutions/43000474413-i-need-access-to-your-api-in-order-to-get-data-or-indicator-values/) who want to be supported on our trading platform." The "TradingView API" packages and the scrapers you'll find don't come from TradingView.

If what you want is Claude reading quotes and placing orders in your Aries account, with your OK on each order, that's the [Aries MCP server](https://finance.dev/mcp-server.md), not a chart.

## Real-Time Data for a TradingView Chart: The Server

You need an Aries account, a personal-token client from [Client Center](https://app.aries.com/client-center/api), and Node.js 22 or later. The server has no packages to install, keeps your client secret off the browser and hands the page two things: past candles and live prices.

```javascript server.mjs theme={null}
// Keeps your Aries credentials on the server and gives the browser
// chart bars (REST) and live prices (Server-Sent Events). Node.js 22+.
import http from 'node:http';
import { readFile } from 'node:fs/promises';

const API = process.env.ARIES_API ?? 'https://api.aries.com';
const WS_URL = API.replace('https://', 'wss://') + '/v1/charts/ws';

let token, tokenExpiresAt = 0;
async function getToken() {
  if (Date.now() < tokenExpiresAt - 60_000) return token; // refresh a minute early
  const res = await fetch(`${API}/v1/oauth2/token`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      grant_type: 'client_credentials',
      client_id: process.env.ARIES_CLIENT_ID,
      client_secret: process.env.ARIES_CLIENT_SECRET,
    }),
  });
  if (!res.ok) throw new Error(`token request failed: ${res.status}`);
  const body = await res.json();
  token = body.access_token;
  tokenExpiresAt = Date.now() + body.expires_in * 1000;
  return token;
}

// GET /history?symbol=AAPL&resolution=5&from=...&to=...  ->  Aries /v1/chart/history
async function history(req, res, params) {
  const upstream = await fetch(`${API}/v1/chart/history?${params}`, {
    headers: { Authorization: `Bearer ${await getToken()}` },
  });
  res.writeHead(upstream.status, { 'Content-Type': 'application/json' });
  res.end(await upstream.text());
}

// GET /stream?symbol=AAPL  ->  one Aries charting WebSocket per open chart
async function stream(req, res, params) {
  const symbol = params.get('symbol');
  res.writeHead(200, { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache' });
  const ws = new WebSocket(WS_URL);
  ws.onopen = async () => ws.send(JSON.stringify({
    type: 'request', id: 'auth',
    payload: { method: 'POST', path: '/auth', body: { token: await getToken() } },
  }));
  ws.onmessage = ({ data }) => {
    // One frame can hold several JSON messages, one per line.
    for (const line of String(data).split('\n')) {
      if (!line.trim()) continue;
      const msg = JSON.parse(line);
      if (msg.payload?.action === 'authSuccess') {
        ws.send(JSON.stringify({ type: 'subscribe', id: 'sub', payload: { type: 'quotes', symbol } }));
      } else if (msg.type === 'event') {
        const { trade, quote } = msg.payload.data;
        const price = trade?.lp ?? quote?.v?.lp; // events carry only the fields that changed
        const time = trade?.t ?? Math.floor(msg.payload.timestamp / 1000);
        if (price !== undefined) res.write(`data: ${JSON.stringify({ time, price })}\n\n`);
      } else if (msg.payload?.error) {
        console.error('Aries:', msg.payload.error);
      }
    }
  };
  ws.onclose = () => res.end(); // the browser's EventSource reconnects on its own
  req.on('close', () => ws.close());
}

http.createServer(async (req, res) => {
  const url = new URL(req.url, 'http://localhost');
  try {
    if (url.pathname === '/history') return await history(req, res, url.searchParams);
    if (url.pathname === '/stream') return await stream(req, res, url.searchParams);
    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.end(await readFile(new URL('./index.html', import.meta.url)));
  } catch (err) {
    console.error(err);
    res.writeHead(502).end();
  }
}).listen(3000, () => console.log('Open http://localhost:3000'));
```

* **The token.** The server trades your client ID and secret for an access token with [Client Credentials](https://finance.dev/api-reference/oauth2/client-credentials.md) and gets a new one a minute before it expires.
* **History.** `/history` passes the chart's request to `GET /v1/chart/history`, which returns candles as arrays: `t` (Unix seconds), `o`, `h`, `l`, `c`, `v`.
* **Live prices.** `/stream` opens one [charting WebSocket](https://finance.dev/websockets/tradingview-chart.md) per open chart, signs in with the token, subscribes to the symbol's quotes and sends each price to the browser as Server-Sent Events.
* **Two quirks.** One frame can carry several JSON messages, one per line, and a quote event carries only the fields that changed. If you port this to another language, parse every line and don't expect a price in every event.

This sample signs in as you, so it's for your own chart. For a chart other people use, each person signs in with their own Aries account through [OAuth2 with PKCE](https://finance.dev/api-reference/oauth2/guide.md).

## TradingView Lightweight Charts: The Page With Live Candles

Save this as `index.html` next to `server.mjs`. It loads Lightweight Charts from a CDN. In a bundled app, run `npm install lightweight-charts` and import `createChart` and `CandlestickSeries` instead.

```html index.html theme={null}
<!doctype html>
<html>
<body style="margin:0">
<div id="chart" style="height:100vh"></div>
<script src="https://unpkg.com/lightweight-charts@5.3.0/dist/lightweight-charts.standalone.production.js"></script>
<script type="module">
const SYMBOL = 'AAPL', RESOLUTION = 5, STEP = RESOLUTION * 60; // 5-minute candles

// Lightweight Charts works in UTC, so label the axis in New York time.
const nyTime = (t) => new Date(t * 1000).toLocaleTimeString('en-US',
  { timeZone: 'America/New_York', hour: '2-digit', minute: '2-digit' });
const chart = LightweightCharts.createChart(document.getElementById('chart'), {
  timeScale: { timeVisible: true, tickMarkFormatter: nyTime },
  localization: { timeFormatter: nyTime },
});
const candles = chart.addSeries(LightweightCharts.CandlestickSeries);

// 1. History: the last few days of finished candles.
const now = Math.floor(Date.now() / 1000);
const h = await (await fetch(
  `/history?symbol=${SYMBOL}&resolution=${RESOLUTION}&from=${now - 5 * 86400}&to=${now}`)).json();
const bars = h.t.map((time, i) => ({ time, open: h.o[i], high: h.h[i], low: h.l[i], close: h.c[i] }));
candles.setData(bars);
let last = bars.at(-1);

// 2. Live: fold each price into the current candle, or start a new one.
new EventSource(`/stream?symbol=${SYMBOL}`).onmessage = ({ data }) => {
  const { time, price } = JSON.parse(data);
  const start = time - (time % STEP);
  if (start < last.time) return; // an old print: the chart only moves forward
  last = start > last.time
    ? { time: start, open: price, high: price, low: price, close: price }
    : { ...last, high: Math.max(last.high, price), low: Math.min(last.low, price), close: price };
  candles.update(last);
};
</script>
</body>
</html>
```

`setData` draws the history once. After that, every price lands in a 5-minute slot. A price in the current slot moves that candle's high, low and close, and a price in a new slot starts a new one. `update` only replaces the last candle or adds a newer one, so a late trade for an earlier slot is dropped.

Run it with your client's credentials:

```bash theme={null}
export ARIES_CLIENT_ID="ARI-PERSONAL-TK.your-client-id"
export ARIES_CLIENT_SECRET="your-client-secret"
node server.mjs
```

Open `http://localhost:3000`. To try it on the Aries staging server first, also set `ARIES_API=https://api.tradearies.dev`. Before the market opens, the stream sends bid and ask changes but no trades, so the last candle starts moving with the first trade of the session.

![A TradingView Lightweight Charts candlestick chart of AAPL in 5-minute candles over three sessions, from about \$345 to \$360, with times on the axis in New York time and the last price, 358.54, marked on the right. TradingView's attribution mark sits in the bottom left corner.](https://mintcdn.com/ariesfinancialinc/bcmjSv-aQa23w5pb/images/guides/tradingview-api-live-chart.png?fit=max\&auto=format\&n=bcmjSv-aQa23w5pb\&q=85\&s=a839167a2cbfa66f86d7532ed1f795b4)

The page above on the Aries staging server: AAPL 5-minute candles through the close on Nov 27, 2026. AAPL is an example, not a recommendation.

## Is TradingView Lightweight Charts Free?

Yes. Lightweight Charts is open source under the Apache 2.0 license. The license asks you to keep TradingView's attribution notice and a link to tradingview\.com on the page. The small TradingView logo the chart shows by default, the `attributionLogo` option, covers the link, so leave it on unless your page links to TradingView elsewhere.

For a dark chart, pass colors in `layout` and `grid` when you create it:

```javascript theme={null}
layout: { background: { color: '#090C0D' }, textColor: '#D1D4DC' },
grid: { vertLines: { color: '#1F2427' }, horzLines: { color: '#1F2427' } },
```

![The candlestick chart on a dark background: AAPL 5-minute candles from late morning on Nov 25 to the 1:00 PM close on Nov 27, 2026, between about \$345 and \$360, with the last price, 358.54, marked on the right and TradingView's attribution mark in the bottom left corner.](https://mintcdn.com/ariesfinancialinc/bcmjSv-aQa23w5pb/images/guides/tradingview-api-dark-chart.png?fit=max\&auto=format\&n=bcmjSv-aQa23w5pb\&q=85\&s=6d30e947f05f064361abb2ec6b9d5f17)

The same page with those colors: AAPL 5-minute candles from Nov 25 and Nov 27, 2026, from the Aries staging server.

## TradingView Charting Library (Advanced Charts) With the Aries API

TradingView's Advanced Charts, the library with drawing tools and indicators, is free but not open: "[These licenses are only available to companies](https://www.tradingview.com/free-charting-libraries/) for use in public web projects and/or applications." For a live chart in your own app, we'd start with Lightweight Charts and reach for Advanced Charts only when your users need those. If your company has that license, Aries' chart endpoints already answer in the shape of its UDF datafeed:

| UDF endpoint | Aries API |
| - | - |
| `/config` | `GET /v1/chart/config` |
| `/symbols` | `GET /v1/chart/symbols?symbol=AAPL` |
| `/search` | `GET /v1/chart/search?query=AAP&limit=10` |
| `/history` | `GET /v1/chart/history` |
| `/time` | `GET /v1/chart/time` |
| `/quotes` | `GET /v1/chart/quotes?symbols=AAPL,MSFT` |

Every Aries call needs a Bearer token, and TradingView's UDF adapter has no documented way to add one. TradingView also recommends its Datafeed API for real-time data. So write a small datafeed: point `getBars` at your server's `/history` and `subscribeBars` at its `/stream`, fold prices into bars the way the page above does, and keep the token on the server.

For every message and field on the stream, see the [Charting WebSocket reference](https://finance.dev/websockets/tradingview-chart.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.