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

# Candles (OHLC)

> Subscribe to Open, High, Low and Close (OHLC) candle data for specific interval periods

<div className="api-banner">
  <span className="api-protocol ws">WSS</span>
  <span className="api-detail">ws.kraken.com/v2</span>
  <span className="api-tag">ohlc</span>
</div>

The `ohlc` channel streams the Open, High, Low and Close (OHLC) data for the specific interval period.

The feed accepts a list of symbols for subscription and the updates are generated on trade events.

## Subscribe

There is an acknowledgement response for each symbol in the subscription list.

<Tabs>
  <Tab title="Request">
    <ResponseField name="method" type="string" required>
      Value: `subscribe`
    </ResponseField>

    <ResponseField name="params" type="object" required>
      <Expandable title="properties" defaultOpen>
        <ResponseField name="channel" type="string" required>
          Value: `ohlc`
        </ResponseField>

        <ResponseField name="symbol" type="string[]" required>
          <span className="field-attr">Example:</span> `["BTC/USD", "MATIC/GBP"]`

          A list of currency pairs.
        </ResponseField>

        <ResponseField name="interval" type="integer">
          <span className="field-attr">One of:</span> `1`, `5`, `15`, `30`, `60`, `240`, `1440`, `10080`, `21600`

          The interval timeframe in minutes.
        </ResponseField>

        <ResponseField name="snapshot" type="boolean">
          <span className="field-attr">One of:</span> `true`, `false`<br />
          <span className="field-attr">Default:</span> `true`

          Request a snapshot after subscribing.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="req_id" type="integer">
      Optional client originated request identifier sent as acknowledgment in the response.
    </ResponseField>
  </Tab>

  <Tab title="Response">
    <ResponseField name="method" type="string" required>
      Value: `subscribe`
    </ResponseField>

    <ResponseField name="result" type="object">
      <Expandable title="properties" defaultOpen>
        <ResponseField name="channel" type="string" required>
          Value: `ohlc`
        </ResponseField>

        <ResponseField name="symbol" type="string" required>
          <span className="field-attr">Example:</span> `"BTC/USD"`

          The currency pair associated with this subscription.
        </ResponseField>

        <ResponseField name="snapshot" type="boolean">
          Indicates if a snapshot is requested.
        </ResponseField>

        <ResponseField name="interval" type="integer">
          The requested OHLC interval in minutes.
        </ResponseField>

        <ResponseField name="warnings" type="string[]">
          An advisory message, highlighting deprecated fields or upcoming changes to the channel.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="success" type="boolean">
      Indicates if the request was successfully processed by the engine. One of: `true`, `false`
    </ResponseField>

    <ResponseField name="error" type="string">
      Error message. Condition: if `success` is `false`.
    </ResponseField>

    <ResponseField name="time_in" type="string">
      The timestamp when the subscription was received on the wire, just prior to parsing data. Format: RFC3339. Example: `2022-12-25T09:30:59.123456Z`
    </ResponseField>

    <ResponseField name="time_out" type="string">
      The timestamp when the acknowledgement was sent on the wire, just prior to transmitting data. Format: RFC3339. Example: `2022-12-25T09:30:59.123456Z`
    </ResponseField>

    <ResponseField name="req_id" type="integer">
      Optional client originated request identifier sent as acknowledgment in the response.
    </ResponseField>
  </Tab>
</Tabs>

## Snapshot / Update

The snapshot and update responses share the same schema. An update message is streamed on a trade event.

<ResponseField name="channel" type="string">
  Value: `ohlc`
</ResponseField>

<ResponseField name="type" type="string">
  <span className="field-attr">One of:</span> `snapshot`, `update`
</ResponseField>

<ResponseField name="data" type="object[]">
  A list of candle events.

  <Expandable title="properties" defaultOpen>
    <ResponseField name="symbol" type="string">
      <span className="field-attr">Example:</span> `"BTC/USD"`

      The symbol of the currency pair.
    </ResponseField>

    <ResponseField name="open" type="float">The opening trade price within the interval.</ResponseField>
    <ResponseField name="high" type="float">The highest trade price within the interval.</ResponseField>
    <ResponseField name="low" type="float">The lowest trade price within the interval.</ResponseField>
    <ResponseField name="close" type="float">The last trade price within the interval.</ResponseField>
    <ResponseField name="vwap" type="float">Volume weighted average trade price within the interval.</ResponseField>
    <ResponseField name="trades" type="integer">Number of trades within the interval.</ResponseField>
    <ResponseField name="volume" type="float">Total traded volume (in base currency terms) within the interval.</ResponseField>

    <ResponseField name="interval_begin" type="string">
      <span className="field-attr">Format:</span> RFC3339<br />
      <span className="field-attr">Example:</span> `2022-12-25T09:30:59.123456Z`

      The timestamp of start of the interval.
    </ResponseField>

    <ResponseField name="interval" type="integer">The timeframe from the interval in minutes.</ResponseField>

    <ResponseField name="timestamp" type="string" deprecated>
      <span className="field-attr">Format:</span> RFC3339<br />
      <span className="field-attr">Example:</span> `2022-12-25T09:30:59.123456Z`<br />
      <span className="field-attr">Deprecated:</span> Use `interval_begin`

      The timestamp of start of the interval.
    </ResponseField>
  </Expandable>
</ResponseField>

## Unsubscribe

There is an acknowledgement response for each symbol in the unsubscribe list.

<Tabs>
  <Tab title="Request">
    <ResponseField name="method" type="string" required>
      Value: `unsubscribe`
    </ResponseField>

    <ResponseField name="params" type="object" required>
      <Expandable title="properties" defaultOpen>
        <ResponseField name="channel" type="string" required>
          Value: `ohlc`
        </ResponseField>

        <ResponseField name="symbol" type="string[]" required>
          <span className="field-attr">Example:</span> `["BTC/USD", "MATIC/GBP"]`

          A list of currency pairs.
        </ResponseField>

        <ResponseField name="interval" type="integer">
          <span className="field-attr">One of:</span> `1`, `5`, `15`, `30`, `60`, `240`, `1440`, `10080`, `21600`

          The interval timeframe in minutes.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="req_id" type="integer">
      Optional client originated request identifier sent as acknowledgment in the response.
    </ResponseField>
  </Tab>

  <Tab title="Response">
    <ResponseField name="method" type="string" required>
      Value: `unsubscribe`
    </ResponseField>

    <ResponseField name="result" type="object">
      <Expandable title="properties" defaultOpen>
        <ResponseField name="channel" type="string" required>
          Value: `ohlc`
        </ResponseField>

        <ResponseField name="symbol" type="string" required>
          <span className="field-attr">Example:</span> `"BTC/USD"`

          The currency pair associated with this subscription.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="success" type="boolean">
      Indicates if the request was successfully processed by the engine. One of: `true`, `false`
    </ResponseField>

    <ResponseField name="error" type="string">
      Error message. Condition: if `success` is `false`.
    </ResponseField>

    <ResponseField name="time_in" type="string">
      The timestamp when the subscription was received on the wire, just prior to parsing data. Format: RFC3339. Example: `2022-12-25T09:30:59.123456Z`
    </ResponseField>

    <ResponseField name="time_out" type="string">
      The timestamp when the acknowledgement was sent on the wire, just prior to transmitting data. Format: RFC3339. Example: `2022-12-25T09:30:59.123456Z`
    </ResponseField>

    <ResponseField name="req_id" type="integer">
      Optional client originated request identifier sent as acknowledgment in the response.
    </ResponseField>
  </Tab>
</Tabs>

<Panel>
  <CodeGroup>
    ```json Subscribe Request theme={null}
    {
        "method": "subscribe",
        "params": {
            "channel": "ohlc",
            "symbol": [
                "ALGO/USD",
                "MATIC/USD"
            ],
            "interval": 5
        }
    }
    ```

    ```json Subscribe Response theme={null}
    {
        "method": "subscribe",
        "result": {
            "channel": "ohlc",
            "interval": 5,
            "snapshot": true,
            "symbol": "ALGO/USD",
            "warnings": [
                "timestamp is deprecated, use interval_begin"
            ]
        },
        "success": true,
        "time_in": "2023-10-04T16:26:01.802708Z",
        "time_out": "2023-10-04T16:26:01.802791Z"
    }

    {
        "method": "subscribe",
        "result": {
            "channel": "ohlc",
            "interval": 5,
            "snapshot": true,
            "symbol": "MATIC/USD",
            "warnings": [
                "timestamp is deprecated, use interval_begin"
            ]
        },
        "success": true,
        "time_in": "2023-10-04T16:26:01.802708Z",
        "time_out": "2023-10-04T16:26:01.802791Z"
    }
    ```
  </CodeGroup>

  <CodeGroup>
    ```json Snapshot theme={null}
    {
        "channel": "ohlc",
        "type": "snapshot",
        "timestamp": "2023-10-04T16:26:01.806315597Z",
        "data": [
            {
                "symbol": "ALGO/USD",
                "open": 0.09875,
                "high": 0.09875,
                "low": 0.09875,
                "close": 0.09875,
                "trades": 1,
                "volume": 201.86015,
                "vwap": 0.09875,
                "interval_begin": "2023-10-04T15:25:00.000000000Z",
                "interval": 5,
                "timestamp": "2023-10-04T15:30:00.000000Z"
            },
            {
                "symbol": "ALGO/USD",
                "open": 0.09875,
                "high": 0.0988,
                "low": 0.09875,
                "close": 0.09875,
                "trades": 13,
                "volume": 16255.46368,
                "vwap": 0.09879,
                "interval_begin": "2023-10-04T15:30:00.000000000Z",
                "interval": 5,
                "timestamp": "2023-10-04T15:35:00.000000Z"
            }
        ]
    }
    ```

    ```json Update theme={null}
    {
        "channel": "ohlc",
        "type": "update",
        "timestamp": "2023-10-04T16:26:30.524394914Z",
        "data": [
            {
                "symbol": "MATIC/USD",
                "open": 0.5624,
                "high": 0.5628,
                "low": 0.5622,
                "close": 0.5627,
                "trades": 12,
                "volume": 30927.68066226,
                "vwap": 0.5626,
                "interval_begin": "2023-10-04T16:25:00.000000000Z",
                "interval": 5,
                "timestamp": "2023-10-04T16:30:00.000000Z"
            }
        ]
    }
    ```
  </CodeGroup>

  <CodeGroup>
    ```json Unsubscribe Request theme={null}
    {
        "method": "unsubscribe",
        "params": {
            "channel": "ohlc",
            "symbol": [
                "ALGO/USD",
                "MATIC/USD"
            ],
            "interval": 5
        }
    }
    ```

    ```json Unsubscribe Response theme={null}
    {
        "method": "unsubscribe",
        "result": {
            "channel": "ohlc",
            "interval": 5,
            "symbol": "ALGO/USD"
        },
        "success": true,
        "time_in": "2023-10-04T16:26:01.802708Z",
        "time_out": "2023-10-04T16:26:01.802791Z"
    }

    {
        "method": "unsubscribe",
        "result": {
            "channel": "ohlc",
            "interval": 5,
            "symbol": "MATIC/USD"
        },
        "success": true,
        "time_in": "2023-10-04T16:26:01.802708Z",
        "time_out": "2023-10-04T16:26:01.802791Z"
    }
    ```
  </CodeGroup>
</Panel>
