Skip to main content

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.

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

getPriceFeed(
  tokenAddress: string,
  feedProps: PriceFeedProps,
  quoteTokenAddress?: string,
  options?: AvnuOptions
): Promise<DataPoint[] | CandleDataPoint[]>

Parameters

tokenAddress
string
required
Token contract address to get price history for
feedProps
PriceFeedProps
required
Price feed configuration
quoteTokenAddress
string
Quote currency address (defaults to USD). Use ETH address for ETH-denominated prices.
options
AvnuOptions
Optional SDK configuration

Returns

Returns Promise<DataPoint[]> for LINE type or Promise<CandleDataPoint[]> for CANDLE type.
// 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

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)}`);

Resolution Guidelines

Recommended resolutions by time range:
Time RangeBest ResolutionData Points
1 hour1 or 5 min12-60 points
1 day5 or 15 min96-288 points
1 week1 hour168 points
1 month4 hour or 1 day30-180 points
1 year1 day or 1 week52-365 points

Get Market Data

Get current market data for all tokens

Get Token Data

Get detailed data for a specific token

API Reference

REST API price history endpoint

Markets Overview

Learn about Markets API