A live candlestick chart with volume for any Robinhood Chain token (here Tesla’s tokenized stock, TSLA), built on /candles and TradingView Lightweight Charts. Paste any token address or pick an interval; it refreshes every 15 seconds.
TSLA
Loading… The code
Section titled “The code”The candles endpoint returns columnar arrays (t, o, h, l, c, v), which map straight onto chart series:
<div id="chart" style="height: 420px"></div><script type="module"> import { createChart, CandlestickSeries, HistogramSeries } from "https://unpkg.com/lightweight-charts@5.2.1/dist/lightweight-charts.standalone.production.mjs";
const token = "0x322f0929c4625ed5bad873c95208d54e1c003b2d"; // TSLA, Tesla tokenized stock const res = await fetch(`https://api.crius.sh/v1/robinhood/token/${token}/candles?interval=15m&limit=300&fill=true`); const { data } = await res.json();
const chart = createChart(document.getElementById("chart"), { autoSize: true }); const candles = chart.addSeries(CandlestickSeries); const volume = chart.addSeries(HistogramSeries, { priceScaleId: "", priceFormat: { type: "volume" } }); volume.priceScale().applyOptions({ scaleMargins: { top: 0.8, bottom: 0 } });
candles.setData(data.t.map((t, i) => ({ time: t / 1000, // the API uses unix milliseconds; the chart wants seconds open: data.o[i], high: data.h[i], low: data.l[i], close: data.c[i], }))); volume.setData(data.t.map((t, i) => ({ time: t / 1000, value: data.v[i] }))); chart.timeScale().fitContent();</script>Make it real-time
Section titled “Make it real-time”Polling works, but the WebSocket stream pushes the live candle as trades happen. Subscribe to candles:<token>:<interval> and update the last bar:
// Run this where your key is safe (your backend, a desktop app), never in a public page.const ws = new WebSocket(`wss://api.crius.sh/v1/robinhood/stream?api_key=${KEY}`);ws.onopen = () => ws.send(JSON.stringify({ op: "subscribe", channels: [`candles:${token}:15m`] }));ws.onmessage = (e) => { const m = JSON.parse(e.data); if (!m.ch.startsWith("candles:")) return; const c = m.data; candles.update({ time: c.t / 1000, open: c.o, high: c.h, low: c.l, close: c.c }); volume.update({ time: c.t / 1000, value: c.v });};