> ## 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 by ID

> To get the OHLC chart (Open, High, Low, Close) of a coin 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).
* The timestamp in the response indicates the **close** time of each OHLC candle.
* Auto-granularity (candle body):
  * 1–2 days: 30 minutes
  * 3–30 days: 4 hours
  * 31 days and beyond: 4 days
* For better granularity, consider [Coin Historical Chart Data](/demo/reference/coins-id-market-chart).

<Note>
  The last completed UTC day (00:00) is available 35 minutes after midnight (00:35 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="15 minutes" />

#### SDK Examples

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

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

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

  print(response)
  ```
</CodeGroup>


## OpenAPI

````yaml openapi-specs/demo-api.json get /coins/{id}/ohlc
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}/ohlc:
    get:
      summary: Coin OHLC Chart by ID
      description: >-
        To get the OHLC chart (Open, High, Low, Close) of a coin based on
        particular coin ID
      operationId: coins-id-ohlc
      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: days
          in: query
          required: true
          description: Data up to number of days ago.
          schema:
            type: string
            default: '1'
            enum:
              - '1'
              - '7'
              - '14'
              - '30'
              - '90'
              - '180'
              - '365'
        - 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 OHLC chart data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CoinsOHLC'
              example:
                - - 1779199200000
                  - 76769
                  - 76889
                  - 76744
                  - 76818
                - - 1779201000000
                  - 76712
                  - 76712
                  - 76321
                  - 76422
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-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)

````