> For the complete documentation index, see [llms.txt](https://hertzflow.gitbook.io/hertzflow-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hertzflow.gitbook.io/hertzflow-docs/tech-docs/api/kline-candlestick-api.md).

# Kline (Candlestick) API

### Endpoint

```
GET /api/v1/historyKLines
```

Base URL: `https://kline-query.testnet.htzfl.link`

### Parameters

| Parameter    | Type   | Required | Description                                  |
| ------------ | ------ | -------- | -------------------------------------------- |
| `symbol`     | string | Yes      | Trading pair symbol (e.g., ETH/USD, BTC/USD) |
| `interval`   | string | Yes      | Candlestick interval                         |
| `start_time` | number | No       | Start timestamp (seconds)                    |
| `end_time`   | number | No       | End timestamp (seconds)                      |
| `limit`      | number | No       | Number of candles to return                  |

#### Supported Intervals

| Interval | Description |
| -------- | ----------- |
| `1m`     | 1 minute    |
| `5m`     | 5 minutes   |
| `15m`    | 15 minutes  |
| `30m`    | 30 minutes  |
| `1h`     | 1 hour      |
| `4h`     | 4 hours     |
| `1d`     | 1 day       |
| `1w`     | 1 week      |

### Response

```json
{
  "code": 200,
  "data": {
    "candles": [
      {
        "symbol": "ETH/USD",
        "interval": "15m",
        "timestamp": 1768996800,
        "open": "2942.98999999",
        "high": "2945.46380963",
        "low": "2915.3465715",
        "close": "2919.80854177",
        "volume": "0",
        "volume_quote": "0",
        "trade_count": 0,
        "oracle_count": 900,
        "is_empty": false
      },
      {
        "symbol": "ETH/USD",
        "interval": "15m",
        "timestamp": 1768997700,
        "open": "2920.23433006",
        "high": "2921.5978459444186",
        "low": "2902.17999999",
        "close": "2910.11",
        "volume": "0",
        "volume_quote": "0",
        "trade_count": 0,
        "oracle_count": 900,
        "is_empty": false
      }
    ]
  },
  "is_success": true,
  "msg": ""
}
```

### Response Fields

#### Top-level Fields

| Field        | Type    | Description                        |
| ------------ | ------- | ---------------------------------- |
| `code`       | number  | HTTP status code (200 for success) |
| `data`       | object  | Response data containing candles   |
| `is_success` | boolean | Whether the request was successful |
| `msg`        | string  | Error message (empty on success)   |

#### Candle Fields

| Field          | Type    | Description                      |
| -------------- | ------- | -------------------------------- |
| `symbol`       | string  | Trading pair symbol              |
| `interval`     | string  | Candlestick interval             |
| `timestamp`    | number  | Candle open time (Unix seconds)  |
| `open`         | string  | Opening price (USD)              |
| `high`         | string  | Highest price (USD)              |
| `low`          | string  | Lowest price (USD)               |
| `close`        | string  | Closing price (USD)              |
| `volume`       | string  | Trading volume in base token     |
| `volume_quote` | string  | Trading volume in quote currency |
| `trade_count`  | number  | Number of trades in this candle  |
| `oracle_count` | number  | Number of oracle price updates   |
| `is_empty`     | boolean | Whether the candle has no data   |

### Error Codes

| Code  | Description                |
| ----- | -------------------------- |
| `400` | Invalid request parameters |
| `404` | Symbol not found           |
| `500` | Internal server error      |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hertzflow.gitbook.io/hertzflow-docs/tech-docs/api/kline-candlestick-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
