> ## Documentation Index
> Fetch the complete documentation index at: https://docs.codex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# onPricesUpdated

> Live-streamed price updates for multiple tokens. Reference for the onPricesUpdated subscription in the Codex API: arguments, payload fields, and usage.

## GraphQL

```
type Subscription {
  # Requires a Growth or Enterprise plan.
  onPricesUpdated(
    input: [OnPricesUpdatedInput!]!
    useWeightedPrices: Boolean
  ): Price!
}

type Price {
  address: String!
  timestamp: Int
  networkId: Int!
  priceUsd: Float!
  blockNumber: Int
  liquidityUsd: String
  priceChange24: Float
}

input OnPricesUpdatedInput {
  address: String!
  networkId: Int!
  sourcePairAddress: String
}
```

### Example

[Test this query in the Explorer →](https://docs.codex.io/explore.md)

```graphql theme={null}
subscription {
  onPricesUpdated(
    input: [
      { address: "So11111111111111111111111111111111111111112", networkId: 1399811149 }
      { address: "TOKEN_ADDRESS", networkId: 1399811149 }
    ]
  ) {
    address
    networkId
    priceUsd
    timestamp
    blockNumber
  }
}
```

```json Example Response theme={null}
{
  "data": {
    "onPricesUpdated": {
      "address": "So11111111111111111111111111111111111111112",
      "networkId": 1399811149,
      "priceUsd": 126.5510281931495,
      "timestamp": 1769560979,
      "blockNumber": 396375165
    }
  }
}
```

> [!NOTE]
>
> **Need every price update across an entire network?** That capability lives on [`onPriceUpdated`](https://docs.codex.io/api-reference/subscriptions/onpriceupdated), not here — `onPricesUpdated` always requires an explicit token list. Network-wide streaming is a dedicated add-on billed at a flat monthly rate per network, with package discounts for more than one network, and must be enabled for your account before use. Contact us at [hello@codex.io](mailto:hello@codex.io?subject=Network-wide%20Price%20Updates) or on [Telegram](https://t.me/CodexData) to get set up.

### Usage Guidelines

* Pass an array of `{ address, networkId }` objects to subscribe to price updates for multiple tokens in a single subscription
* Tokens can span different networks — e.g., SOL on Solana and WETH on Ethereum in one subscription
* Each update delivers a single `Price` object for whichever token's price changed — not a batch of all tokens at once
* Optionally include `sourcePairAddress` per token to override the default pricing pool
* Up to 25 tokens per subscription (hard limit on the input array). You may have multiple `onPricesUpdated` subscriptions on a connection
* There is no hard limit on subscriptions per connection — what matters is the **total number of tokens being watched** across them. As a starting point, plan for up to \~100 tokens per connection. For high-volume tokens (SOL, top trending tokens, busy pairs), lower the per-connection density and open more connections instead
* Your internet connection, and geolocation (proximity to US-West), may affect connection health and speeds, especially with many subscriptions
* See our [Subscriptions](https://docs.codex.io/concepts/subscriptions.md) concept for more information

### Troubleshooting Tips

> [accordion] Token prices are changing between API calls for the same timestamp
>
> On chains with sub-second block times (like BSC), multiple price updates can occur within a single second. Since blockchain timestamps only have 1-second precision, multiple different prices can validly exist for the same timestamp.
>
> To workaround this, we've added a `blockNumber` input and response field. This will give you pricing accuracy down to the blocknumber if blockchain timestamps are causing unexpected pricing discrepancies.\\

> [accordion] If I subscribe to multiple trading pairs, can I later cancel a certain trading pair?
>
> Yes. You should be able to use shouldResubscribe for this. ([https://www.apollographql.com/docs/react/data/subscriptions#options](https://www.apollographql.com/docs/react/data/subscriptions#options))

> [accordion] When should I use onPricesUpdated vs onPriceUpdated?
>
> Use `onPricesUpdated` when tracking multiple tokens — it lets you batch them into a single subscription instead of opening one subscription per token. Use `onPriceUpdated` if you only need a single token's price feed.

> [accordion] Do I get updates for all tokens at once?
>
> No. Each message contains a single `Price` object for whichever token's price just changed. High-volume tokens will produce updates more frequently than low-volume ones.

> [accordion] Is there a subscription that streams every token's price across a network?
>
> Not via `onPricesUpdated` — it caps at 25 tokens per `input` array and always requires an explicit token list. To watch a larger set, run multiple `onPricesUpdated` subscriptions on the same connection and add/remove tokens by closing and reopening individual subscriptions (you don't need to drop the connection).\
> \
> For true network-wide streams, [`onPriceUpdated`](https://docs.codex.io/api-reference/subscriptions/onpriceupdated) supports streaming every price update on a network as a dedicated add-on — billed at a flat monthly rate per network (package discounts for multiple networks), currently available on Solana, BNB, Base, Robinhood, and more. It must be enabled for your account first: contact us at [hello@codex.io](mailto:hello@codex.io?subject=Network-wide%20Price%20Updates) or on [Telegram](https://t.me/CodexData) to get set up.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.