> ## 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.

# getTokenPrices

> Returns real-time or historical prices for a list of tokens, fetched in batches. getTokenPrices query reference: arguments and response fields.

## GraphQL

```
type Query {
  getTokenPrices(
    inputs: [GetPriceInput]
  ): [Price]
}

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

input GetPriceInput {
  address: String!
  networkId: Int!
  timestamp: Int
  poolAddress: String
  blockNumber: Int
}
```

### Example

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

```graphql theme={null}
{
  getTokenPrices(
    inputs: {address: "So11111111111111111111111111111111111111112", networkId: 1399811149}
  ) {
    address
    networkId
    priceUsd
    timestamp
  }
}
```

### Usage Guidelines

* Prices returns are aggregate values weighted across all valid pools. Provide a pool address if you want prices only from a specific pool.
* We recommend `getDetailedPairStats` for the most accurate historical price and volume data
* Accepts up to 25 inputs per request. Extra inputs are dropped without an error, so split larger lists into batches of 25.
* With `timestamp`, the price returned is the most recent one at or before that time. Check the returned `timestamp` to see when it was set.
* A token's price changes only when one of its own pools trades. If its quote token (for example WETH or SOL) moves while the token doesn't trade, the USD price stays where it was. `timestamp` and `blockNumber` mark when the price was last set.

### Troubleshooting Tips

> [accordion] My query is not returning a pool address, is this expected?
>
> Yes. We added a deprecated value to that field (along with deprecating `confidence`). It returns `null` if no pool is specified in the input as the expected behavior is an aggregated price across all pools, not one specific pool. The previous default would be to use the top-pair if no pool was specified.

> [accordion] I'm not able to get all the information I need from this endpoint, can we add additional fields in the results?
>
> Unfortunately not. `getTokenPrices` was built to be as fast as possible, so we don't want to slow it down by adding additional data points to it. Our team is happy to discuss options of how to obtain all the data you need in as few queries as possible.

### Related Recipes

* [Discover Tokens](https://docs.codex.io/recipes/discover-tokens.md): Build token discovery pages with trending data, filters, and search


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