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

# Get Price Feed

> Fetch historical price data for charting and analysis using the SDK

## Overview

Get historical price data for any token with customizable time ranges and resolutions. Returns line or candlestick data perfect for building price charts, analyzing trends, and backtesting strategies.

## SDK Method

```typescript theme={null}
getPriceFeed(
  tokenAddress: string,
  feedProps: PriceFeedProps,
  quoteTokenAddress?: string,
  options?: AvnuOptions
): Promise<DataPoint[] | CandleDataPoint[]>
```

## Parameters

<ParamField path="tokenAddress" type="string" required>
  Token contract address to get price history for
</ParamField>

<ParamField path="feedProps" type="PriceFeedProps" required>
  Price feed configuration

  <Expandable title="PriceFeedProps properties">
    <ParamField path="type" type="PriceFeedType" required>
      Data format: `PriceFeedType.LINE` or `PriceFeedType.CANDLE`
    </ParamField>

    <ParamField path="dateRange" type="FeedDateRange" required>
      Time period:

      * `FeedDateRange.ONE_HOUR`
      * `FeedDateRange.ONE_DAY`
      * `FeedDateRange.ONE_WEEK`
      * `FeedDateRange.ONE_MONTH`
      * `FeedDateRange.ONE_YEAR`
    </ParamField>

    <ParamField path="resolution" type="FeedResolution" required>
      Data point frequency:

      * `FeedResolution.ONE_MIN` - 1 minute
      * `FeedResolution.FIVE_MIN` - 5 minutes
      * `FeedResolution.FIFTEEN_MIN` - 15 minutes
      * `FeedResolution.HOURLY` - 1 hour
      * `FeedResolution.FOUR_HOUR` - 4 hours
      * `FeedResolution.DAILY` - 1 day
      * `FeedResolution.WEEKLY` - 1 week
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="quoteTokenAddress" type="string">
  Quote currency address (defaults to USD). Use ETH address for ETH-denominated prices.
</ParamField>

<ParamField path="options" type="AvnuOptions">
  Optional SDK configuration
</ParamField>

## Returns

Returns `Promise<DataPoint[]>` for LINE type or `Promise<CandleDataPoint[]>` for CANDLE type.

```typescript theme={null}
// LINE type response
interface DataPoint {
  date: string;           // ISO 8601 timestamp
  value: number;          // Price value
}

// CANDLE type response
interface CandleDataPoint {
  date: string;           // ISO 8601 timestamp
  open: number;
  high: number;
  low: number;
  close: number;
  volume: number;
}
```

## Examples

<CodeGroup>
  ```typescript Line Chart Data theme={null}
  import { getPriceFeed, PriceFeedType, FeedDateRange, FeedResolution } from '@avnu/avnu-sdk';

  const ETH = '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7';

  // Get 7-day price history with 1-hour resolution
  const priceData = await getPriceFeed(
    ETH,
    {
      type: PriceFeedType.LINE,
      dateRange: FeedDateRange.ONE_WEEK,
      resolution: FeedResolution.HOURLY
    }
  );

  console.log(`Fetched ${priceData.length} data points`);

  priceData.forEach(point => {
    console.log(`${point.date}: $${point.value.toFixed(2)}`);
  });

  // Calculate price statistics
  const prices = priceData.map(p => p.value);
  const avgPrice = prices.reduce((a, b) => a + b) / prices.length;
  const maxPrice = Math.max(...prices);
  const minPrice = Math.min(...prices);

  console.log(`7-day Stats: Avg: $${avgPrice.toFixed(2)}, High: $${maxPrice.toFixed(2)}, Low: $${minPrice.toFixed(2)}`);
  ```

  ```typescript Candlestick Data theme={null}
  import { getPriceFeed, PriceFeedType, FeedDateRange, FeedResolution } from '@avnu/avnu-sdk';

  const ETH = '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7';

  // Get 30-day candlestick data with daily resolution
  const candleData = await getPriceFeed(
    ETH,
    {
      type: PriceFeedType.CANDLE,
      dateRange: FeedDateRange.ONE_MONTH,
      resolution: FeedResolution.DAILY
    }
  );

  candleData.forEach(candle => {
    const color = candle.close > candle.open ? '🟢' : '🔴';
    console.log(`${color} ${candle.date}`);
    console.log(`  O: $${candle.open.toFixed(2)} H: $${candle.high.toFixed(2)}`);
    console.log(`  L: $${candle.low.toFixed(2)} C: $${candle.close.toFixed(2)}`);
  });
  ```

  ```typescript ETH-Denominated Prices theme={null}
  import { getPriceFeed, PriceFeedType, FeedDateRange, FeedResolution } from '@avnu/avnu-sdk';

  const USDC = '0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8';
  const ETH = '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7';

  // Get USDC price in ETH terms
  const usdcInEth = await getPriceFeed(
    USDC,
    {
      type: PriceFeedType.LINE,
      dateRange: FeedDateRange.ONE_DAY,
      resolution: FeedResolution.HOURLY
    },
    ETH  // Quote in ETH instead of USD
  );

  usdcInEth.forEach(point => {
    console.log(`${point.date}: ${point.value.toFixed(6)} ETH`);
  });
  ```
</CodeGroup>

## Resolution Guidelines

<Info>
  **Recommended resolutions by time range:**

  | Time Range | Best Resolution | Data Points   |
  | ---------- | --------------- | ------------- |
  | 1 hour     | 1 or 5 min      | 12-60 points  |
  | 1 day      | 5 or 15 min     | 96-288 points |
  | 1 week     | 1 hour          | 168 points    |
  | 1 month    | 4 hour or 1 day | 30-180 points |
  | 1 year     | 1 day or 1 week | 52-365 points |
</Info>

## Related

<CardGroup cols={2}>
  <Card title="Get Market Data" icon="chart-simple" href="/docs/markets/get-market-data">
    Get current market data for all tokens
  </Card>

  <Card title="Get Token Data" icon="chart-line" href="/docs/markets/get-token-data">
    Get detailed data for a specific token
  </Card>

  <Card title="API Reference" icon="code" href="/api/markets/price-feed">
    REST API price history endpoint
  </Card>

  <Card title="Markets Overview" icon="book" href="/docs/markets/index">
    Learn about Markets API
  </Card>
</CardGroup>
