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

# Get token price history and OHLCV data

> Get historical crypto price data (OHLCV) for any token across 33 blockchains. Perfect for building charts, backtesting strategies, and price analysis.

## Tutorial overview

Pull historical OHLCV from a pool using `start`, `limit`, and `interval`, with tips for smoothing and inverted ratios.

<Info>
  Having trouble with the API? We're here to help - [drop us a line](mailto:support@coinpaprika.com) and we'll get you sorted.
</Info>

## Why you need historical price data?

Building a crypto app? You'll likely need price charts, volatility analysis, or backtesting data. That's where OHLCV (Open, High, Low, Close, Volume) data comes in - it's the backbone of any serious crypto application.

**Common use cases:**

* **Price charts** in trading apps
* **Backtesting** trading strategies
* **Volatility analysis** for risk management
* **Historical performance** dashboards
* **Market research** and analytics

<Tip>
  **Quick Start**: If you know your token already, jump to [Step 2](#step-2-get-price-history-data) to grab the data immediately.
</Tip>

***

## Step 1: Find your token's trading pool

Here's the thing - historical data comes from actual trading pools, not tokens directly. This makes sense because prices happen where people trade.

### Quick search (recommended)

The fastest way to find what you need using the [Search API](/api-reference/search/search-for-tokens-pools-and-dexes):

```bash theme={null}
curl "https://api.dexpaprika.com/search?query=USDC" | jq
```

**Pro tip**: Search returns tokens, pools, and exchanges. Look for pools with high volume - they'll have the most reliable price data.

### If you have the token address

Skip the search and go straight to pools using the [Token Pools API](/api-reference/tokens/get-top-x-pools-for-a-token):

```bash theme={null}
curl "https://api.dexpaprika.com/networks/ethereum/tokens/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48/pools" | jq
```

<Note>
  Always pick pools with decent volume (>\$10k daily). Low-volume pools can have weird price spikes that don't reflect real market conditions.
</Note>

***

## Step 2: Get price history data

Now for the good stuff. Here's how to pull historical OHLCV data using the [Pool OHLCV API](/api-reference/pools/get-ohlcv-data-for-a-pool-pair):

```bash theme={null}
curl "https://api.dexpaprika.com/networks/ethereum/pools/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640/ohlcv?start=2025-01-01&limit=30&interval=24h&inversed=true" | jq
```

*(Using USDC/ETH pool on Ethereum as example in this tutorial)*

### What these parameters do:

| Parameter  | What It Does                   | Example                        |
| ---------- | ------------------------------ | ------------------------------ |
| `start`    | When to start collecting data  | `2025-01-01` or Unix timestamp |
| `limit`    | How many data points (max 366) | `30` for 30 days               |
| `interval` | Time between each point        | `24h`, `1h`, `5m`, etc.        |
| `end`      | When to stop (optional)        | `2025-01-31`                   |
| `inversed` | Flip the price ratio           | `true` for ETH/USDC → USDC/ETH |

### What you get back:

```json theme={null}
[
  {
    "time_open": "2025-01-30T00:00:00Z",
    "time_close": "2025-01-31T00:00:00Z",
    "open": 3115.1614508315265,
    "high": 3277.717757396331,
    "low": 3097.803416632386,
    "close": 3250.184016286268,
    "volume": 226403988
  }
]
```

Each data point gives you everything you need for candlestick charts or analysis.

***

## Time intervals that actually matter

Choose based on what you're building:

**For Trading Apps:**

* `1m`, `5m` - Real-time trading
* `1h`, `4h` - Swing trading
* `24h` - Position trading

**For Analytics Dashboards:**

* `24h` - Daily summaries
* Use daily data and aggregate for weekly/monthly views

**For Research:**

* `24h` with longer date ranges (up to 1 year)

***

## Production tips that'll save you time

### Cache aggressively

Historical data doesn't change - cache it locally:

```bash theme={null}
# Check when pool was created to avoid requesting non-existent data
curl "https://api.dexpaprika.com/networks/ethereum/pools/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640" | jq '.created_at'
```

### Handle data gaps

Some pools have quiet periods. Here's how to deal with gaps:

```bash theme={null}
# Filter out low-volume periods that might have unreliable prices
curl "https://api.dexpaprika.com/networks/ethereum/pools/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640/ohlcv?start=2025-01-01&limit=30&inversed=true" | jq '.[] | select(.volume > 1000)'
```

### Multi-pool strategy

For major tokens, cross-reference data from multiple pools:

```bash theme={null}
# Get all USDC pools to compare price consistency
curl "https://api.dexpaprika.com/networks/ethereum/tokens/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48/pools?limit=5" | jq '.pools[] | .id'
```

### Rate limiting

Don't hammer the API. We suggest you to batch your requests and cache results:

```javascript theme={null}
// Example: Batch multiple token histories
const tokens = ['USDC', 'WETH', 'USDT'];
const historyPromises = tokens.map(token => 
  fetch(`/api/history/${token}`).then(r => r.json())
);
const allHistories = await Promise.all(historyPromises);
```

***

## Troubleshooting common issues

### "Empty response"

Pool might not have data for your date range:

```bash theme={null}
# Check pool age first
curl "https://api.dexpaprika.com/networks/ethereum/pools/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640" | jq '.created_at'
```

### "Weird price spikes"

You hit a low-liquidity period. Switch to shorter intervals or higher-volume pools:

```bash theme={null}
# Use 6h intervals to smooth out anomalies
curl "https://api.dexpaprika.com/networks/ethereum/pools/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640/ohlcv?start=2025-01-01&interval=6h&limit=50&inversed=true"
```

### "Upside-down prices"

You need the inverted ratio:

```bash theme={null}
# Flip from TOKEN/ETH to ETH/TOKEN
curl "https://api.dexpaprika.com/networks/ethereum/pools/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640/ohlcv?start=2025-01-01&inversed=true&limit=10"
```

***

## What's next?

<CardGroup cols={2}>
  <Card title="Pool details API" icon="chart-line" href="/api-reference/pools/get-a-pool-on-a-network">
    Get liquidity, fees, and other pool metrics.
  </Card>

  <Card title="Real-time price feeds" icon="bolt" href="/tutorials/fetch-token-price">
    Combine historical data with live prices.
  </Card>
</CardGroup>

### FAQs

<AccordionGroup>
  <Accordion title="What if my date range predates the pool?">
    First check the pool’s `created_at`; set `start` to not precede the creation time.
  </Accordion>

  <Accordion title="Which interval should I use?">
    For charts: `1h`/`24h`. For anomaly smoothing: `6h`/`12h`. For near real‑time: `1m`/`5m`.
  </Accordion>

  <Accordion title="Why is volume zero in some windows?">
    No trades occurred in that interval; aggregate longer or switch pools with higher activity.
  </Accordion>

  <Accordion title="How do I invert the pair?">
    Pass `inversed=true` to flip from token0/token1 to token1/token0.
  </Accordion>
</AccordionGroup>

<script type="application/ld+json">
  {JSON.stringify({
      "@context": "https://schema.org",
      "@type": "FAQPage",
      "mainEntity": [
        {"@type": "Question","name": "What if my date range predates the pool?","acceptedAnswer": {"@type": "Answer","text": "Check pool created_at and ensure start is not earlier."}},
        {"@type": "Question","name": "Which interval should I use?","acceptedAnswer": {"@type": "Answer","text": "Charts: 1h/24h; smoothing: 6h/12h; near real‑time: 1m/5m."}},
        {"@type": "Question","name": "Why is volume zero in some windows?","acceptedAnswer": {"@type": "Answer","text": "No trades in that interval; aggregate longer or choose a busier pool."}},
        {"@type": "Question","name": "How do I invert the pair?","acceptedAnswer": {"@type": "Answer","text": "Use inversed=true to flip the price ratio."}}
      ]
    })}
</script>

## Need help?

<CardGroup cols={2}>
  <Card title="Discord community" icon="discord" href="https://discord.gg/DhJge5TUGM">
    Ask questions and see what others are building.
  </Card>

  <Card title="Direct support" icon="message" href="mailto:support@coinpaprika.com">
    Hit a wall? We'll help you debug it.
  </Card>
</CardGroup>
