Skip to main content
This endpoint requires a Growth or Enterprise plan. Learn more.

Returns

Price
See Price

Arguments

String
The token contract address. Required unless you are on an enterprise plan including PriceFeed features.
Int
The network ID the token is deployed on.
String
The pair contract address from which to get pricing. Defaults to the top pair for the token.
Boolean
Whether to subscribe to weighted token prices instead of pair-derived prices. Not supported when sourcePairAddress is provided.

Example

Test this query in the Explorer →
Example Response
Network-wide price streams: onPriceUpdated can also stream every price update across an entire network. 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, with package discounts when you subscribe to more than one network, and it must be enabled for your account before use. Currently available on Solana, BNB, Base, Robinhood, and more. Contact us at hello@codex.io or on Telegram to get set up.

Usage Guidelines

  • Provide address (token contract address) and networkId to subscribe to price updates for a specific token
  • priceUsd returns the current USD price of the token, updated with every on-chain swap
  • Optionally specify sourcePairAddress to get pricing from a specific liquidity pool instead of the default top pair
  • Use blockNumber to track which block the price update originated from
  • This subscription is ideal for simple price feeds — use onBarsUpdated if you need OHLCV candlestick data

Troubleshooting Tips

By default, the price is derived from the token’s top liquidity pair. You can override this by passing a sourcePairAddress to use a specific pool for pricing.
Updates are sent in real-time with every swap that affects the token’s price. High-volume tokens will produce more frequent updates.
Use onPriceUpdated for a simple, real-time price feed (e.g., displaying a live price ticker). Use onBarsUpdated when you need OHLCV candlestick data, volume breakdowns, or multiple time resolutions for charting.
These fields are deprecated. Pricing is no longer based on specific pools, so these values are no longer meaningful. Use blockNumber instead to track the source of price updates.