> ## 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 Market Data

> Fetch market data for all tokens using the SDK

## Overview

Get comprehensive market data for all verified tokens on Starknet, including prices, volume, market cap, and price changes. Perfect for building token lists, market screeners, and portfolio trackers.

## SDK Method

```typescript theme={null}
getMarketData(
  options?: AvnuOptions
): Promise<TokenMarketData[]>
```

## Parameters

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

  <Expandable title="AvnuOptions properties">
    <ParamField path="baseUrl" type="string">
      Custom Impulse API base URL (default: `https://starknet.impulse.avnu.fi`)
    </ParamField>

    <ParamField path="avnuPublicKey" type="string">
      Public key for response verification
    </ParamField>
  </Expandable>
</ParamField>

## Returns

Returns `Promise<TokenMarketData[]>` - Array of market data for all tokens.

```typescript theme={null}
interface TokenMarketData {
  address: string;
  name: string;
  symbol: string;
  decimals: number;
  logoUri?: string | null;
  coingeckoId?: string | null;
  verified: boolean;
  tags: TokenTag[];  // defaults to []
  linePriceFeedInUsd: DataPoint[];
  starknet: StarknetMarket;
  global: GlobalMarket | null;
}

interface StarknetMarket {
  usd: number;
  usdTvl: number;
  usdPriceChange1h: number;
  usdPriceChangePercentage1h: number | null;
  usdPriceChange24h: number;
  usdPriceChangePercentage24h: number | null;
  usdPriceChange7d: number;
  usdPriceChangePercentage7d: number | null;
  usdVolume24h: number;
  usdTradingVolume24h: number;
}

interface GlobalMarket {
  usd: number;
  usdMarketCap: number;
  usdFdv: number;
  usdMarketCapChange24h: number;
  usdMarketCapChangePercentage24h: number;
}

interface DataPoint {
  date: string;
  value: number;
}
```

## Example

<CodeGroup>
  ```typescript Basic Usage theme={null}
  import { getMarketData } from '@avnu/avnu-sdk';

  const marketData = await getMarketData();

  console.log(`Total tokens: ${marketData.length}`);

  // Display top 10 by market cap
  const topByMarketCap = marketData
    .filter(t => t.global?.usdMarketCap)
    .sort((a, b) => (b.global?.usdMarketCap || 0) - (a.global?.usdMarketCap || 0))
    .slice(0, 10);

  topByMarketCap.forEach((token, i) => {
    console.log(`${i + 1}. ${token.symbol}: $${token.starknet.usd.toFixed(2)}`);
    console.log(`   Market Cap: $${((token.global?.usdMarketCap || 0) / 1e6).toFixed(2)}M`);
    console.log(`   24h Change: ${token.starknet.usdPriceChangePercentage24h?.toFixed(2) || 'N/A'}%`);
  });
  ```
</CodeGroup>

## Related

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

  <Card title="Get Price Feed" icon="chart-candlestick" href="/docs/markets/get-price-feed">
    Fetch historical price data
  </Card>

  <Card title="API Reference" icon="code" href="/api/markets">
    REST API endpoints
  </Card>

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