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

# Fetch token price at timestamp

> Price of a token at a given timestamp.

export const SupportedChainsList = props => {
  const [data, setData] = useState(null);
  const [isLoading, setIsLoading] = useState(true);
  useEffect(() => {
    const fetchData = async () => {
      try {
        const response = await fetch("https://api.allium.so/api/v1/supported-chains/realtime-apis", {
          method: "GET"
        });
        if (!response.ok) {
          throw new Error(`HTTP error! status: ${response.status}`);
        }
        const responseData = await response.json();
        const filteredData = responseData.filter(entry => {
          const product = entry.endpoints[props.product_name];
          return product !== null;
        });
        setData(filteredData);
        setIsLoading(false);
      } catch (error) {
        setIsLoading(false);
      }
    };
    fetchData();
  }, []);
  if (isLoading) {
    return <div>Loading chain information...</div>;
  }
  if (!data) {
    return <div>No data available</div>;
  }
  const isCustomSQL = props.product_name === "custom_sql";
  return <div>
            {data.length > 0 && <table className="w-full">
                    <thead>
                        <tr>
                            <th>Chain</th>
                            <th>Chain ID</th>
                            <th>Status</th>
                            {isCustomSQL && <th>Tables</th>}
                        </tr>
                    </thead>
                    <tbody>
                        {data.map(chain => {
    const endpoint = chain.endpoints[props.product_name];
    return <tr key={chain.id}>
                                    <td style={{
      padding: '12px'
    }}>{chain.label}</td>
                                    <td style={{
      padding: '12px'
    }}><code>{chain.id}</code></td>
                                    <td style={{
      padding: '12px'
    }}>{endpoint ? endpoint.availability === "beta" ? "🌱 Beta" : "✅ Supported" : "❌ Not Supported"}</td>
                                    {isCustomSQL && <td style={{
      padding: '12px'
    }}>
                                            {endpoint && endpoint.tables ? endpoint.tables.map(t => t.name).join(", ") : "-"}
                                        </td>}
                                </tr>;
  })}
                    </tbody>
                </table>}
        </div>;
};

This endpoint returns the price of a token at or before a given timestamp. If the token doesn't have a price at the given timestamp (because there weren't any trades at that time), the price will be the price at the closest timestamp before the given timestamp.

Use `staleness_tolerance` to specify the max lookback time for a price.

## time\_granularity

`time_granularity` is the size of the aggregation window over which we aggregate the price. It can be one of the following values: `15s`, `1m`, `5m`, `1h`, `1d`.

**Examples:**

* If you request a price at **3:15** with `1h` granularity, we will return the price at **3:00**. Note that the price at 3:00 is the volume-weighted price of the token between 3:00 and 4:00.

* If you request a price at **3:12** with `5m` granularity, we will return the price at **3:10** (aggregating the price of the token between 3:10 and 3:15).

### Retention Periods

Data at each granularity is retained for different periods.
The following are the retention periods for each supported granularity:

| Granularity | Retention |
| :---------- | :-------- |
| 15s         | 5 days    |
| 1m          | 30 days   |
| 5m          | 30 days   |
| 1h          | All       |
| 1d          | All       |

## staleness\_tolerance

`staleness_tolerance` is an optional string containing a number of seconds, minutes, hours, or days. Use this value to define the max lookback time for a price. For example: `60s`, `5m`, `2h`, `2d`.

Some lower volume tokens are often not traded for hours or days before trading starts again. In these instances, we do not return a price for periods of inactivity to prevent returning a stale price that doesn't represent the actual value of a token.

To customize this behavior, you can use `staleness_tolerance` to define the max lookback time for a price.

### Default Values

| Time Granularity | Default Staleness Tolerance |
| :--------------- | :-------------------------- |
| 15s              | 60s                         |
| 1m               | 5m                          |
| 5m               | 10m                         |
| 1h               | 2h                          |
| 1d               | 2d                          |

## Response

The response contains two timestamps:

* `input_timestamp`: The requested timestamp in the payload
* `price_timestamp`: The timestamp of the latest price found for the token

## Pagination

This endpoint returns prices for up to 200 tokens in a single request.

## Supported Chains

<SupportedChainsList product_name="token_latest_price" />


## OpenAPI

````yaml /_openapi/prices-api.json POST /api/v1/developer/prices/at-timestamp
openapi: 3.1.0
info:
  title: Allium API
  version: 0.1.0
servers:
  - url: https://api.allium.so
security: []
paths:
  /api/v1/developer/prices/at-timestamp:
    post:
      tags:
        - PRICES
        - DEVELOPER
      summary: Get Prices At Timestamp
      description: >-
        Get the price for a list of token addresses at a given timestamp.

        If a token doesn't have a price at the given timestamp (because there
        weren't any trades at that time),

        the price will be the price at the closest timestamp before the given
        timestamp.

        Use 'stalesness_tolerance' to specify the max lookback time (in minutes)
        for a price.

        Args:
            payloads: PayloadTokenAddressAtTimestamp objects containing timestamp, granularity, stalesness_tolerance and a list of token address + chain pairs.
        Returns:
            Dictionary mapping chain types to lists of PayloadTokenAddressAtTimestamp objects
        Example:
            ```
            [
                {
                    "addresses": [
                        {
                            "token_address": "1Qf8gESP4i6CFNWerUSDdLKJ9U1LpqTYvjJ2MM4pain",
                            "chain": "solana"
                        }
                    ],
                    "timestamp": "2025-07-11T00:00:00Z",
                    "time_granularity": "5m",
                    "staleness_tolerance": 120
                }
            ]
            ```
      operationId: get_prices_at_timestamp_api_v1_developer_prices_at_timestamp_post
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PayloadTokenAddressAtTimestamp'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Envelope_TokenPriceAtTimestamp_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyBearer: []
components:
  schemas:
    PayloadTokenAddressAtTimestamp:
      properties:
        addresses:
          items:
            $ref: '#/components/schemas/PayloadTokenAddress'
          type: array
          maxItems: 200
          minItems: 1
          title: Addresses
          description: List of token address+chain pairs
        timestamp:
          type: string
          format: date-time
          title: Timestamp
          description: Target timestamp (UTC ISO 8601)
        time_granularity:
          $ref: >-
            #/components/schemas/api_server__app__services__prices__models__Granularity
          description: Candle granularity (15s, 1m, 5m, 1h, 1d)
        staleness_tolerance:
          anyOf:
            - type: string
              format: duration
            - type: string
            - type: 'null'
          title: Staleness Tolerance
          description: Max lookback for price data (e.g. 1h, 30m)
      type: object
      required:
        - addresses
        - timestamp
        - time_granularity
      title: PayloadTokenAddressAtTimestamp
      example:
        addresses:
          - chain: string
            token_address: string
          - chain: string
            token_address: string
        staleness_tolerance: 1h
        time_granularity: 5m
        timestamp: '2025-03-07T00:00:00Z'
    Envelope_TokenPriceAtTimestamp_:
      properties:
        items:
          items:
            $ref: '#/components/schemas/TokenPriceAtTimestamp'
          type: array
          title: Items
          description: Response items
        cursor:
          anyOf:
            - type: string
            - type: 'null'
          title: Cursor
          description: Pagination cursor for next page
        message:
          anyOf:
            - type: string
            - type: 'null'
          title: Message
          description: Informational message (e.g. partial results)
      type: object
      required:
        - items
      title: Envelope[TokenPriceAtTimestamp]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    PayloadTokenAddress:
      properties:
        token_address:
          type: string
          title: Token Address
          description: Token contract address
        chain:
          type: string
          title: Chain
          description: Lowercase chain name
      type: object
      required:
        - token_address
        - chain
      title: PayloadTokenAddress
      example:
        chain: ethereum
        token_address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
    api_server__app__services__prices__models__Granularity:
      type: string
      enum:
        - 15s
        - 1m
        - 5m
        - 1h
        - 1d
      title: Granularity
    TokenPriceAtTimestamp:
      properties:
        input_timestamp:
          type: string
          format: date-time
          title: Input Timestamp
          description: Requested timestamp
        price_timestamp:
          type: string
          format: date-time
          title: Price Timestamp
          description: Actual price timestamp
        mint:
          type: string
          title: Mint
          description: Token contract address
        chain:
          type: string
          title: Chain
          description: Lowercase chain name
        price:
          type: number
          title: Price
          description: Price (USD) at the actual price timestamp
      type: object
      required:
        - input_timestamp
        - price_timestamp
        - mint
        - chain
        - price
      title: TokenPriceAtTimestamp
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyBearer:
      type: apiKey
      in: header
      name: X-API-KEY

````