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
Token contract address to get price history for
Price feed configuration Show PriceFeedProps properties
Data format: PriceFeedType.LINE or PriceFeedType.CANDLE
Time period:
FeedDateRange.ONE_HOUR
FeedDateRange.ONE_DAY
FeedDateRange.ONE_WEEK
FeedDateRange.ONE_MONTH
FeedDateRange.ONE_YEAR
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
Quote currency address (defaults to USD). Use ETH address for ETH-denominated prices.
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
Line Chart Data
Candlestick Data
ETH-Denominated Prices
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 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