Overview
Get real-time prices for up to 50 tokens in a single request. Returns both global market prices (CoinGecko) and Starknet on-chain prices.
SDK Method
getPrices(
tokenAddresses: string[],
options?: AvnuOptions
): Promise<TokenPriceResponse>
Parameters
Array of token contract addresses (1-50 tokens)
Optional SDK configuration
Returns
interface TokenPrice {
address: string;
decimals: number;
globalMarket: { usd: number } | null; // CoinGecko price
starknetMarket: { usd: number } | null; // On-chain price
}
type TokenPriceResponse = TokenPrice[];
Example
import { getPrices } from '@avnu/avnu-sdk';
const tokens = [
'0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', // ETH
'0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8', // USDC
'0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d' // STRK
];
const prices = await getPrices(tokens);
prices.forEach(price => {
const starknet = price.starknetMarket?.usd ?? 'N/A';
const global = price.globalMarket?.usd ?? 'N/A';
console.log(`${price.address.slice(0, 10)}... Starknet: $${starknet}, Global: $${global}`);
});