Charts
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.
Fetch
Start by implementing the following query to fetch the OHLCV data for a given token.
Render
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.
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.
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