> ## 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 OHLC Chart within Time Range by ID

> To get the OHLC chart (Open, High, Low, Close) of a coin within a range of timestamp 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;
};

export const PlanExclusivity = ({tier}) => {
  if (tier === "enterprise") {
    return <Callout icon="crown" color="#FFC107" iconType="regular">
        <strong>Enterprise Only</strong><br />This endpoint is exclusively available to <strong>Enterprise</strong> plan.<br /><a href="https://www.coingecko.com/en/api/enterprise">→ Contact sales</a>
      </Callout>;
  }
  if (tier === "analyst_above") {
    return <Callout icon="briefcase" color="#FFC107" iconType="regular">
        <strong>Analyst Plan and Above</strong><br />This endpoint is only available to <strong>Analyst, Lite, Pro, and Enterprise</strong> plan.<br /><a href="https://www.coingecko.com/en/api/pricing">→ View pricing</a>
      </Callout>;
  }
  if (tier === "basic_above") {
    return <Callout icon="briefcase" color="#FFC107" iconType="regular">
        <strong>Basic Plan and Above</strong><br />This endpoint is only available to <strong>Basic, Analyst, Lite, Pro, and Enterprise</strong> plan.<br /><a href="https://www.coingecko.com/en/api/pricing">→ View pricing</a>
      </Callout>;
  }
  throw new Error(`PlanExclusivity: invalid tier "${tier}". Use "basic_above", "analyst_above", or "enterprise".`);
};

#### Notes

* Find a coin's API ID on its [CoinGecko](https://www.coingecko.com) page, via [Coins List](/reference/coins-list), or this [Google Sheet](https://docs.google.com/spreadsheets/d/1wTTuxXt8n9q7C4NDXqQpI3wpKu1_5bGVmP9Xz0XGSyU/edit?usp=sharing).
* Accepts ISO date strings (`YYYY-MM-DD` or `YYYY-MM-DDTHH:MM`, recommended) or UNIX timestamps for `from` and `to`.
* The timestamp in the response indicates the **close** time of each OHLC candle.
* Interval options:
  * `daily`: up to 180 days per request (180 candles)
  * `hourly`: up to 31 days per request (744 candles)
* Data available from 9 February 2018 onwards.
* For better granularity, consider [Coin Historical Chart Data](/reference/coins-id-market-chart).

<PlanExclusivity tier="analyst_above" />

<CacheInfo rate="15 minutes" />

#### SDK Examples

<CodeGroup>
  ```typescript TypeScript theme={null}
  const response = await client.coins.ohlc.getRange('bitcoin', {
    vs_currency: 'usd',
    from: '2025-12-01',
    to: '2025-12-31',
    interval: 'daily',
  });

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

  ```python Python theme={null}
  response = client.coins.ohlc.get_range(
    "bitcoin",
    vs_currency="usd",
    from_="2025-12-01",
    to="2025-12-31",
    interval="daily",
  )

  print(response)
  ```
</CodeGroup>


## OpenAPI

````yaml openapi-specs/pro-api.json get /coins/{id}/ohlc/range
openapi: 3.0.0
info:
  title: CoinGecko Pro API
  version: 3.0.0
servers:
  - url: https://pro-api.coingecko.com/api/v3
security:
  - headerAuth: []
  - queryAuth: []
paths:
  /coins/{id}/ohlc/range:
    get:
      summary: Coin OHLC Chart within Time Range by ID
      description: >-
        To get the OHLC chart (Open, High, Low, Close) of a coin within a range
        of timestamp based on particular coin ID
      operationId: coins-id-ohlc-range
      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 price data. 

            *refers to
            [`/simple/supported_vs_currencies`](/reference/simple-supported-currencies).
          schema:
            type: string
            default: usd
        - name: from
          in: query
          required: true
          description: >-
            Starting date in ISO date string (`YYYY-MM-DD` or
            `YYYY-MM-DDTHH:MM`) or UNIX timestamp. 

            **Use ISO date string for best compatibility.**
          schema:
            type: string
            default: '2025-12-01'
        - name: to
          in: query
          required: true
          description: >-
            Ending date in ISO date string (`YYYY-MM-DD` or `YYYY-MM-DDTHH:MM`)
            or UNIX timestamp. 

            **Use ISO date string for best compatibility.**
          schema:
            type: string
            default: '2025-12-31'
        - name: interval
          in: query
          required: true
          description: Data interval.
          schema:
            type: string
            default: daily
            enum:
              - daily
              - hourly
      responses:
        '200':
          description: Coin OHLC chart data within time range
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CoinsOHLC'
              example:
                - - 1764547200000
                  - 90832
                  - 91905
                  - 90406
                  - 90406
                - - 1764633600000
                  - 90360
                  - 90360
                  - 83989
                  - 86281
components:
  schemas:
    CoinsOHLC:
      type: array
      description: OHLC data points as [timestamp, open, high, low, close] arrays
      items:
        type: array
        items:
          type: number
  securitySchemes:
    headerAuth:
      type: apiKey
      in: header
      name: x-cg-pro-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_pro_api_key
      description: >-
        Learn how to [set up your API
        key](https://docs.coingecko.com/docs/setting-up-your-api-key)

````