Learn how to render a token chart with the Codex API
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.
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
The result uses the “response-as-a-table” pattern, which means you can use the 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.
Now that we have all the data we need to render a chart, we can use the onBarsUpdated subscription to get realtime updates.
Realtime
After receiving the realtime updates, you can use the o
, h
, l
, c
, t
, and volume
fields to update the chart.
Check out the rest of the similar queries and subscriptions in the api reference