time in unix seconds, TradingView-style interval keys accepted as aliases, traded bars only (TradingView’s has_empty_bars draws the empty ones if you want them), and pagination that maps one-to-one to getBars. This guide wires GET /v1/token/ohlcv into both TradingView products, then makes the bars live.
- Advanced Charts (the Charting Library): the full-featured widget behind Axiom, GMGN and every major terminal. Free, but TradingView grants the library access on request; you host the files, you feed the data.
- Lightweight Charts: TradingView’s open-source npm package. A few KB, no approval process, perfect for list previews and compact charts.
The symbol convention
A chart needs one string per market. Use the token’s identity as the ticker,<chain>:<address>:
chain is a public chain id (evm:8453, solana), so the same datafeed serves all 19 EVM chains and Solana.
Resolutions
Our intervals cover every resolution the widget offers, seconds included. The full map:The datafeed
The whole integration is one object implementing four methods.getBars is a direct translation of the endpoint’s paging contract: endTime is TradingView’s to (both unix seconds), limit is countBack, and noData is true when a page comes back empty with meta.hasMore false.
datafeed.ts
fill=true if you want a flat bar for every empty bucket), and a token that graduated from a bonding curve draws one continuous series across the migration, curve history stitched in server-side.
Mounting the widget is standard TradingView:
Live bars
subscribeBars is one subscription on the ohlcv channel: the forming candle of the same series as getBars (same main pool, same candle shape, time in unix seconds), pushed as it changes, then each closed candle the moment its bucket rolls over. Every event is the complete candle: hand it to onTick, TradingView replaces the bar with the same time. stream is the connection helper of the terminal guide.
since set to the last cursor you received: the candles closed meanwhile come back first, then the forming one. If the stream answers REPLAY_TOO_OLD, call the widget’s onResetCacheNeededCallback and chart.resetData() so getBars re-seeds the series from REST.
Lightweight Charts
The open-source package expectstime in unix seconds: our candles drop in with no conversion at all.
The details that bite
- Time units. REST candles and Lightweight Charts use unix seconds; Advanced Charts bars want milliseconds. The
* 1000ingetBarsis the whole difference. pricescalemust be an integer power of ten. Size it from the token’s price atresolveSymboltime (helper above) or microcap charts render as a flat line.- Volume.
volumeTokenis the base-asset volume, the number a TradingView volume pane expects.volumeis the quote-side value if you prefer notional. - Paging depth. Up to 2000 candles per
getBarscall,limithonoured however quiet the token is; historical pages are immutable and cached, so scroll-back stays fast. - Interval aliases. The API also accepts
1min,5min,15min,30min,60,7d,30ddirectly and echoes the canonical key inmeta.interval, so a partial map still works during a migration from another provider. - Credits. A
getBarspage is 5 credits; live bars bill 1 credit per update a trade moved, andupdatePeriodon the subscription (say1000for one update per second) bounds the burn of a busy token. Full grid on Authentication & Limits.
Build a Trading Terminal
The rest of the terminal around this chart: discovery, tape, panels, portfolio.
Token Candles reference
Every parameter and semantic of the endpoint behind the datafeed.