This endpoint requires a Growth or Enterprise plan. Learn more.
Returns
OnTokenBarsUpdatedResponse
Arguments
String
The ID of the token (
address:networkId). Required unless you are on an enterprise plan including BarFeed features.[BarCommitmentLevel!]
The commitment levels to subscribe to.
See BarCommitmentLevel
Int
The networkId to use when getting all bars per network.
Pricing for aggregate charts will no longer only use the top pair. Weighted average pricing will be used across a token’s top pairs, based on liquidity/recency, while filtering out lower quality pairs from contributing.
Network-wide bar streams (BarFeed):
onTokenBarsUpdated can also stream aggregated bars for every token on a network by passing networkId and omitting tokenId, so you do not need to know token addresses in advance. This capability isn’t part of standard plans — it’s a dedicated add-on billed at a flat monthly rate per network rather than per request, and it must be enabled before use. The BarFeed entitlement is attached to specific API keys, not to your account as a whole: a key without the entitlement still requires tokenId and returns arguments: tokenId required on field: onTokenBarsUpdated but missing. If you need it on more than one key, ask us to enable each key. Contact us at hello@codex.io or on Telegram to get set up.Example
Test this query in the Explorer →Example Response
Usage Guidelines
- Subscribe using
tokenIdin the formattokenAddress:networkIdto stream aggregate bar data for a token - With the BarFeed add-on enabled on your API key, pass
networkId(and omittokenId) to stream bars for every token on that network. Only the resolutions you request are returned, so keep the selection small (for exampler5S) on a network-wide stream - Unlike
onBarsUpdated(which tracks a single pair), this subscription aggregates pricing across a token’s top liquidity pairs using weighted averages aggregatescontains OHLCV bar data across multiple resolutions simultaneously (e.g.,r1for 1-minute,r5for 5-minute,r60for 1-hour)- Each resolution provides both
usd(USD-denominated) andtoken(native token-denominated) bars viaCurrencyBarData - Granular trade metrics like
buyers,sellers,buyVolume,sellVolume, andliquidityare available per bar - The default
statsTypeisFILTERED, which excludes bot and sandwich attack transactions - Use the
volumestring field for precise volume data — thevinteger field may benullfor aggregate token bars
Troubleshooting Tips
How does this differ from onBarsUpdated?
How does this differ from onBarsUpdated?
onBarsUpdated streams bar data for a single trading pair. onTokenBarsUpdated aggregates pricing across a token’s top liquidity pairs using weighted averages based on liquidity and recency, filtering out lower-quality pairs. Use onTokenBarsUpdated for a holistic view of a token’s price, and onBarsUpdated when you need data for a specific pair.What resolutions are available?
What resolutions are available?
Resolutions range from 1-second (
r1S) up to 1-week (r7D): r1S, r5S, r15S, r30S, r1 (1 min), r5, r15, r30, r60, r240 (4h), r720 (12h), r1D, r7D. You only need to request the resolutions you need in your query.Why is the v field null?
Why is the v field null?
The
v integer field may be null for aggregate token bars. Use the volume string field instead, which provides precise volume data as a string to avoid floating-point precision issues.Why do I get 'tokenId required' when subscribing by networkId?
Why do I get 'tokenId required' when subscribing by networkId?
Network-wide bar streams require the BarFeed entitlement, which is enabled per API key rather than per account. If one of your keys works and another returns
arguments: tokenId required on field: onTokenBarsUpdated but missing, the second key does not have the entitlement. Contact hello@codex.io to enable it on additional keys. The same applies to the network-wide onPriceUpdated stream (PriceFeed).What does statsType: Filtered vs Unfiltered mean?
What does statsType: Filtered vs Unfiltered mean?
Filtered excludes suspected bot and sandwich attack transactions for cleaner price data. Unfiltered includes all transactions. Most charting use cases should use Filtered for more accurate price representation.Related Recipes
- Detailed Token Page: Build a comprehensive token detail page with price, holders, trades, and real-time updates
- Charts: Render token charts with OHLCV data and real-time updates