# DefiLlama — Get historical prices for multiple tokens at multiple different timestamps

Get DefiLlama Batch Token Prices data via REST or OpenAny MCP—with pay-per-use pricing and no subscription. Powered by DeFiLlama, pass parameters such as coins, and retrieve structured data including coins, <coin>, token ticker symbol, prices, and confidence for compute transaction cost basis, backtest multi-asset strategies, and reduce request fan-out, ready for production pipelines and AI agent automation.

Documentation: https://openany.si/defillama/defillama-get-historical-prices-for-multiple-tokens-at-multiple-different-timestamps/162f157b-d226-47e3-add2-04a1e0ffe283/
API ID: 162f157b-d226-47e3-add2-04a1e0ffe283
Provider: defillama
Contract revision: 5
Method: GET
Endpoint: https://api.openany.si/v1/agent-apis/defillama/batchHistorical
Page update time: 2026-12-03T02:39:15.349Z
Access: OpenAny REST
OpenAny MCP: availability is not supplied by this REST contract. Check get_api on the configured OpenAny MCP server before execution.
Request content type: none
Execution mode: sync
Authentication: Authorization: Bearer $OPENANY_API_KEY

## Billing
Price: $0 / call
The published contract currently has no usage charge. Authentication and service limits still apply.
Price source: OpenAny public API contract.
Contract update time: 2026-12-03T02:39:11.946Z. This is not a price-change timestamp.
```json
{
  "currency": "USD",
  "mode": "fixed",
  "priceMicroUsd": "0",
  "rounding": null,
  "unit": "call",
  "unitQuantity": null
}
```

## Usage and limits
## DefiLlama Batch Token Prices API

Send a URL-encoded JSON string in the required `coins` query parameter where each key is `{chain}:{address}` (or `coingecko:{id}`) and each value is an array of UNIX timestamps. The response returns per-coin `symbol` and `prices[]` entries.

## What You Can Build

- **Compute transaction cost basis**: Price dozens of historical swaps at their exact block timestamps in one API call.
- **Backtest multi-asset strategies**: Retrieve aligned or staggered historical quotes across Avalanche, Ethereum and CoinGecko IDs.
- **Reduce request fan-out**: Replace loops of single-timestamp historical lookups with one batched query.

## Returned Data

| Field | Meaning |
| --- | --- |
| `coins` | Map of requested token identifiers to historical price bundles |
| `coins.<coin>` | Historical price bundle keyed by {chain}:{address} |
| `coins.<coin>.symbol` | Token ticker symbol |
| `coins.<coin>.prices` | Array of matched historical price observations |
| `coins.<coin>.prices[].timestamp` | UNIX timestamp of the returned price point |
| `coins.<coin>.prices[].price` | Historical token price in USD |
| `coins.<coin>.prices[].confidence` | Confidence score for the historical price quote |

## Request parameters
```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "DefiLlama — Get historical prices for multiple tokens at multiple different timestamps request inputs",
  "$comment": "Declared input types grouped by HTTP location. Path, query and header values describe decoded inputs and are serialized as text on the wire; body is the payload. This is not an exhaustive provider contract or a schema for the raw HTTP request.",
  "type": "object",
  "properties": {
    "path": {
      "type": "object",
      "properties": {}
    },
    "query": {
      "type": "object",
      "properties": {
        "coins": {
          "type": "string",
          "description": "object where keys are coins in the form {chain}:{address}, and values are arrays of requested timestamps"
        }
      },
      "required": [
        "coins"
      ]
    },
    "headers": {
      "type": "object",
      "properties": {}
    }
  },
  "required": [
    "path",
    "query",
    "headers"
  ]
}
```

## Response fields
Source: Inferred from examples; not an exhaustive provider schema.
```json
{
  "type": "object",
  "properties": {
    "coins": {
      "type": "object",
      "properties": {
        "avax:0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e": {
          "type": "object",
          "properties": {
            "prices": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "confidence": {
                    "type": "number"
                  },
                  "price": {
                    "type": "number"
                  },
                  "timestamp": {
                    "type": "integer"
                  }
                }
              }
            },
            "symbol": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}
```

## Request example
Scenario: Official UI example (not runtime verified)
```bash
curl \
  'https://api.openany.si/v1/agent-apis/defillama/batchHistorical?coins=%7B%22avax%3A0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e%22%3A+%5B1666876743%2C+1666862343%5D%2C+%22coingecko%3Aethereum%22%3A+%5B1666869543%2C+1666862343%5D%7D%0A' \
  -X GET \
  -H "Authorization: Bearer $OPENANY_API_KEY" \
  -H 'Content-Type: application/json'
```

## Response example
Published documentation example. Verify the actual response after an approved call.
Sample response · Documented HTTP 200
```json
{
  "coins": {
    "avax:0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e": {
      "prices": [
        {
          "confidence": 0.99,
          "price": 0.999436,
          "timestamp": 1666876674
        }
      ],
      "symbol": "USDC"
    }
  }
}
```

## Error handling
400: Check the request fields.
401 / 403: Verify credentials and access permissions.
402: Inspect payment requirements and balance.
429: Respect returned retry guidance.
5xx: Inspect the error and usage record before retrying a paid operation.

## Common questions
### How should I format the coins query parameter?
Pass a JSON object string where keys are {chain}:{address} (or coingecko:{id}) and values are arrays of UNIX timestamps.

### Do all tokens in one batch need the same timestamps?
No. Each token key can specify its own array of UNIX timestamps.

### What fields are inside each prices array entry?
Each entry contains timestamp, price (USD) and confidence.

### Can I mix on-chain contract addresses and CoinGecko IDs?
Yes. The reference request combines an Avalanche contract address with coingecko:ethereum.

### When should I use this instead of Historical Token Prices?
Use Batch Token Prices when you need multiple different timestamps per call; use Historical Token Prices for one shared timestamp.

### When should I use Token Price Chart instead?
Use the DefiLlama Token Price Chart API when you want evenly spaced interval series defined by start, end, span and period.

## Available implementations
- defillama: https://openany.si/defillama/defillama-get-historical-prices-for-multiple-tokens-at-multiple-different-timestamps/162f157b-d226-47e3-add2-04a1e0ffe283/

Integration guide: https://openany.si/docs/
Agent setup: https://openany.si/SKILL.md
