In this recipe we’ll show you how to use the Codex api to render a token chart, complete with OHLCV data, and more. This data powers the charts on defined.fi.

Fetch
Start by implementing the following query to fetch the OHLCV data for a given token.Chart for BNB token for day with 5 minute bars
Render
Sample Response
o, h, l, c, t, and volume fields to render the chart. This is adapted from the TradingView documentation, and is intended to be used with their charting library here.Realtime updates
Now that we have all the data we need to render a chart, we can use the onBarsUpdated subscription to get realtime updates.Realtime
o, h, l, c, t, and volume fields to update the chart.
Aggregated Charts
Create token charts with aggregated data across all valid pairs with getTokenBars. Note that this data has limited historical data, back to timestamp1753121580.
For real-time aggregate charts, subscribe to onTokenBarsUpdated.
You can refer to this datafeed example using the SDK for
onTokenBarsUpdated to get you started with a chart rendering subscription.Check out all of our charting queries and subscriptions in the api reference