> ## 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.

# Coin Historical Chart Data by ID

> To get the historical chart data of a coin including time in UNIX, price, market cap and 24hrs volume based on particular coin ID

export const CacheInfo = ({publicRate, paidRate, rate}) => {
  const fmt = v => v === 0 ? 'Real-time (Cacheless)' : `Every ${v}`;
  if (rate !== undefined) {
    return <Callout icon="clock-rotate-left" color="#2196F3" iconType="regular">
        <strong>Cache / Update Frequency:</strong><br />{fmt(rate)}
      </Callout>;
  }
  if (publicRate !== undefined && paidRate !== undefined) {
    return <Callout icon="clock-rotate-left" color="#2196F3" iconType="regular">
        <strong>Cache / Update Frequency:</strong><ul><li>{fmt(paidRate)} (Paid API)</li><li>{fmt(publicRate)} (Demo / Keyless API)</li></ul>
      </Callout>;
  }
  return null;
};

#### Notes

* Find a coin's API ID on its [CoinGecko](https://www.coingecko.com) page, via [Coins List](/demo/reference/coins-list), or this [Google Sheet](https://docs.google.com/spreadsheets/d/1wTTuxXt8n9q7C4NDXqQpI3wpKu1_5bGVmP9Xz0XGSyU/edit?usp=sharing).
* Auto-granularity when `interval` is not specified:
  * 1 day from current time = **5-minutely** data
  * 2–90 days = **hourly** data
  * Above 90 days = **daily** data (00:00 UTC)
* Override with the `interval` parameter:
  * `daily`: daily historical data
  * `hourly`: hourly data, up to the **past 100 days**
  * `5m`: 5-minutely data, up to the **past 10 days** (Enterprise only)

<Note>
  The last completed UTC day (00:00) data is available 10 minutes after midnight (00:10 UTC).
</Note>

<Warning>
  Historical data via the Demo API is restricted to the past 365 days. Subscribe to a [paid plan](https://www.coingecko.com/en/api/pricing) for the full range.
</Warning>

<CacheInfo rate="30 seconds" />

#### SDK Examples

<CodeGroup>
  ```typescript TypeScript theme={null}
  const response = await client.coins.marketChart.get('bitcoin', {
    vs_currency: 'usd',
    days: '1',
  });

  console.log(JSON.stringify(response, null, 2));
  ```

  ```python Python theme={null}
  response = client.coins.market_chart.get(
    "bitcoin",
    vs_currency="usd",
    days="1",
  )

  print(response.model_dump_json(indent=2))
  ```
</CodeGroup>


## OpenAPI

````yaml openapi-specs/demo-api.json get /coins/{id}/market_chart
openapi: 3.0.0
info:
  title: CoinGecko Demo API
  version: 3.0.0
servers:
  - url: https://api.coingecko.com/api/v3
security:
  - headerAuth: []
  - queryAuth: []
paths:
  /coins/{id}/market_chart:
    get:
      summary: Coin Historical Chart Data by ID
      description: >-
        To get the historical chart data of a coin including time in UNIX,
        price, market cap and 24hrs volume based on particular coin ID
      operationId: coins-id-market-chart
      parameters:
        - name: id
          in: path
          required: true
          description: |-
            Coin ID. 
            *refers to [`/coins/list`](/reference/coins-list).
          schema:
            type: string
            default: bitcoin
        - name: vs_currency
          in: query
          required: true
          description: >-
            Target currency of market data. 

            *refers to
            [`/simple/supported_vs_currencies`](/reference/simple-supported-currencies).
          schema:
            type: string
            default: usd
        - name: days
          in: query
          required: true
          description: |-
            Data up to number of days ago. 
            You may use any integer or `max` for number of days.
          schema:
            type: string
            default: '1'
        - name: interval
          in: query
          required: false
          description: Data interval, leave empty for auto granularity.
          schema:
            type: string
            enum:
              - hourly
              - daily
        - name: precision
          in: query
          required: false
          description: Decimal place for currency price value.
          schema:
            type: string
            enum:
              - full
              - '0'
              - '1'
              - '2'
              - '3'
              - '4'
              - '5'
              - '6'
              - '7'
              - '8'
              - '9'
              - '10'
              - '11'
              - '12'
              - '13'
              - '14'
              - '15'
              - '16'
              - '17'
              - '18'
      responses:
        '200':
          description: Coin historical chart data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CoinsMarketChart'
              example:
                prices:
                  - - 1779027899041
                    - 77953.82550382407
                  - - 1779028199661
                    - 78052.87543398788
                market_caps:
                  - - 1779027899041
                    - 1560631481361.8042
                  - - 1779028199661
                    - 1562027330524.267
                total_volumes:
                  - - 1779027899041
                    - 18688431751.857048
                  - - 1779028199661
                    - 18974828816.446976
components:
  schemas:
    CoinsMarketChart:
      type: object
      required:
        - prices
        - market_caps
        - total_volumes
      properties:
        prices:
          type: array
          description: Price data points as [timestamp, price] pairs
          items:
            type: array
            items:
              type: number
        market_caps:
          type: array
          description: Market cap data points as [timestamp, market_cap] pairs
          items:
            type: array
            items:
              type: number
        total_volumes:
          type: array
          description: Total volume data points as [timestamp, volume] pairs
          items:
            type: array
            items:
              type: number
  securitySchemes:
    headerAuth:
      type: apiKey
      in: header
      name: x-cg-demo-api-key
      description: >-
        Learn how to [set up your API
        key](https://docs.coingecko.com/docs/setting-up-your-api-key)
    queryAuth:
      type: apiKey
      in: query
      name: x_cg_demo_api_key
      description: >-
        Learn how to [set up your API
        key](https://docs.coingecko.com/docs/setting-up-your-api-key)

````