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

# Portfolio Tracking

> Build portfolio trackers with real-time valuation, cost basis, and multi-currency support from CoinGecko API

<CardGroup cols={2}>
  <Card title="Set up your API key" icon="key" href="/docs/setting-up-your-api-key" horizontal arrow="true" />

  <Card title="Build faster with AI" icon="robot" href="/ai-integration#coding-agents" horizontal arrow="true" />
</CardGroup>

<Note>
  **TL;DR**<br />

  Use [/simple/price](/reference/simple-price) for live valuation, [/coins/\{id}/history](/reference/coins-id-history) for cost basis on purchase dates, [/coins/markets](/reference/coins-markets) for dashboard data, and [/coins/\{id}/market\_chart](/reference/coins-id-market-chart) for performance charts.
</Note>

> Replace `YOUR_API_KEY` in the examples below with your actual key. [Get one here →](https://www.coingecko.com/en/api/pricing)

## Portfolio Workflow

<Steps>
  <Step title="Set up currency preference — /simple/supported_vs_currencies">
    Fetch all supported fiat and crypto currencies to populate a currency selector in your UI.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/simple/supported_vs_currencies" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Supported Currencies →](/reference/simple-supported-currencies)
      </Tab>

      <Tab title="Demo API">
        ```bash theme={null}
        curl -X GET \
          "https://api.coingecko.com/api/v3/simple/supported_vs_currencies" \
          -H "x-cg-demo-api-key: YOUR_API_KEY"
        ```

        > [Supported Currencies →](/demo/reference/simple-supported-currencies)
      </Tab>
    </Tabs>

    ```json theme={null}
    ["btc", "eth", "usd", "eur", "jpy", "gbp", "aud", "cad", "sgd", "myr", ...]
    ```

    Pass the user's choice as `vs_currencies` to pricing endpoints.
  </Step>

  <Step title="Live valuation — /simple/price">
    Poll spot prices for all holdings. Batch multiple coins in one call — minimal overhead for frequent polling.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,solana&vs_currencies=usd,eur&include_market_cap=true&include_24hr_change=true" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Simple Price →](/reference/simple-price)
      </Tab>

      <Tab title="Demo API">
        ```bash theme={null}
        curl -X GET \
          "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,solana&vs_currencies=usd,eur&include_market_cap=true&include_24hr_change=true" \
          -H "x-cg-demo-api-key: YOUR_API_KEY"
        ```

        > [Simple Price →](/demo/reference/simple-price)
      </Tab>
    </Tabs>

    ```json theme={null}
    {
      "bitcoin": {
        "usd": 67432.51,
        "eur": 62145.30,
        "usd_market_cap": 1326789012345,
        "usd_24h_change": 2.34
      }
    }
    ```

    Multiply each price by your holding quantity, then sum for total portfolio value.
  </Step>

  <Step title="Token prices by contract — /simple/token_price/{id}">
    For ERC-20 and other contract-based tokens — look up prices by contract address instead of coin ID.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/simple/token_price/ethereum?contract_addresses=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48,0x6b175474e89094c44da98b954eedeac495271d0f&vs_currencies=usd&include_market_cap=true" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Simple Token Price →](/reference/simple-token-price)
      </Tab>

      <Tab title="Demo API">
        ```bash theme={null}
        curl -X GET \
          "https://api.coingecko.com/api/v3/simple/token_price/ethereum?contract_addresses=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48,0x6b175474e89094c44da98b954eedeac495271d0f&vs_currencies=usd&include_market_cap=true" \
          -H "x-cg-demo-api-key: YOUR_API_KEY"
        ```

        > [Simple Token Price →](/demo/reference/simple-token-price)
      </Tab>
    </Tabs>

    | Key param            | Use                                                        |
    | -------------------- | ---------------------------------------------------------- |
    | `id` (path)          | Asset platform — `ethereum`, `polygon-pos`, `solana`, etc. |
    | `contract_addresses` | Comma-separated token addresses                            |

    <Tip>
      For onchain tokens not listed on CoinGecko, use [Onchain Simple Price](/reference/onchain-simple-price) — returns prices by contract address across any supported network.
    </Tip>
  </Step>

  <Step title="Dashboard data — /coins/markets">
    Rich market data for up to 250 coins per page — rankings, sparklines, highs/lows, and multi-timeframe changes.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin,ethereum,solana&sparkline=true&price_change_percentage=1h,24h,7d,30d" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Coins Markets →](/reference/coins-markets)
      </Tab>

      <Tab title="Demo API">
        ```bash theme={null}
        curl -X GET \
          "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin,ethereum,solana&sparkline=true&price_change_percentage=1h,24h,7d,30d" \
          -H "x-cg-demo-api-key: YOUR_API_KEY"
        ```

        > [Coins Markets →](/demo/reference/coins-markets)
      </Tab>
    </Tabs>

    | Key param                 | Use                                             |
    | ------------------------- | ----------------------------------------------- |
    | `ids`                     | Filter to your portfolio coins only             |
    | `sparkline`               | 7-day sparkline data for inline mini-charts     |
    | `price_change_percentage` | `1h,24h,7d,30d` for multi-timeframe performance |
  </Step>

  <Step title="Cost basis — /coins/{id}/history">
    Price snapshot on a specific date — calculate cost basis for each purchase.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/coins/bitcoin/history?date=15-01-2024" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Coin Historical Data →](/reference/coins-id-history)
      </Tab>

      <Tab title="Demo API">
        ```bash theme={null}
        curl -X GET \
          "https://api.coingecko.com/api/v3/coins/bitcoin/history?date=15-01-2024" \
          -H "x-cg-demo-api-key: YOUR_API_KEY"
        ```

        > [Coin Historical Data →](/demo/reference/coins-id-history)
      </Tab>
    </Tabs>

    ```json theme={null}
    {
      "market_data": {
        "current_price": {
          "usd": 42856.23,
          "eur": 39456.78
        }
      }
    }
    ```

    <Note>
      The `date` parameter uses **dd-mm-yyyy** format (not ISO). Data returned is a snapshot at **00:00:00 UTC**.
    </Note>
  </Step>

  <Step title="Performance charts — /coins/{id}/market_chart">
    Price, market cap, and volume over time — for charting portfolio value and calculating time-weighted returns.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/coins/ethereum/market_chart?vs_currency=usd&days=365&interval=daily" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Coin Market Chart →](/reference/coins-id-market-chart)
      </Tab>

      <Tab title="Demo API">
        ```bash theme={null}
        curl -X GET \
          "https://api.coingecko.com/api/v3/coins/ethereum/market_chart?vs_currency=usd&days=365&interval=daily" \
          -H "x-cg-demo-api-key: YOUR_API_KEY"
        ```

        > [Coin Market Chart →](/demo/reference/coins-id-market-chart)
      </Tab>
    </Tabs>

    | Key param  | Use                                                              |
    | ---------- | ---------------------------------------------------------------- |
    | `days`     | Lookback: `1`, `7`, `14`, `30`, `90`, `180`, `365`, or `max`     |
    | `interval` | `daily` for consistent data points, or omit for auto granularity |

    <Tip>
      For tokens tracked by contract address, use [Contract Address Market Chart](/reference/contract-address-market-chart) — same data, queried by address instead of coin ID.
    </Tip>
  </Step>
</Steps>
