> For the complete documentation index, see [llms.txt](https://docs.infoway.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.infoway.io/rest-api/http-endpoints/get-candles.md).

# POST 获取产品的历史/实时K线(Candles)

获取股票、加密货币、外汇、能源、商品等所有产品的实时买卖盘口

### 接口说明

该接口获取股票、加密货币、外汇、能源、商品等所有产品的历史/实时 K 线（Candles）。**本页不是盘口接口。**

本接口为 **POST**，Body 为 JSON。

### 请求频率

与其他 HTTP 接口共用[频率限制](/getting-started/api-limitation/http.md)，具体每秒次数由套餐决定。

### 错误码说明

见 [HTTP错误码](/getting-started/error-codes/http.md)。常见：`503` K 线根数超限，`505` 产品数超限，`508` 产品不存在，`513` 历史时间戳超出套餐。

地址总览见 [行情地址说明](/getting-started/api-endpoints.md)。

### 接口地址

| 市场              | 完整路径                                            |
| --------------- | ----------------------------------------------- |
| 股票（美股、港股、A 股）   | `https://data.infoway.io/stock/v2/batch_kline`  |
| 日本              | `https://data.infoway.io/japan/v2/batch_kline`  |
| 印度              | `https://data.infoway.io/india/v2/batch_kline`  |
| 韩国              | `https://data.infoway.io/korea/v2/batch_kline`  |
| 台湾              | `https://data.infoway.io/taiwan/v2/batch_kline` |
| 加密货币            | `https://data.infoway.io/crypto/v2/batch_kline` |
| 外汇、能源、商品、贵金属、期货 | `https://data.infoway.io/common/v2/batch_kline` |

A 股用 `.SH` / `.SZ`，港股 5 位补零，见 标的代码约定。

### 请求头

| 参数       | 类型     | 必填 | 描述         |
| -------- | ------ | -- | ---------- |
| `apiKey` | String | 是  | 套餐 API Key |

### 入参示例

```json
{
    "klineType": 1,
    "klineNum": 10,
    "codes": "TSLA.US,AAPL.US",
    "timestamp": 1758553860
}
```

| 参数名         | 类型     | 必填 | 描述                                                                        | 示例值               |
| ----------- | ------ | -- | ------------------------------------------------------------------------- | ----------------- |
| `klineType` | int    | 是  | 1：1 分钟；2：5 分钟；3：15 分钟；4：30 分钟；5：1 小时；6：2 小时；7：4 小时；8：日；9：周；10：月；11：季；12：年 | `1`               |
| `klineNum`  | int    | 是  | 单产品最多 500 根；多产品同时查只能各取最近 2 根                                              | `500`             |
| `codes`     | String | 是  | 逗号分隔，最多 100 个                                                             | `TSLA.US,AAPL.US` |
| `timestamp` | long   | 否  | 秒时间戳，只对分钟 / 小时 K 生效。不传则查最近 K。可查范围由套餐决定                                    | `1727007864`      |

### 返回示例

```json
{
    "ret": 200,
    "msg": "success",
    "traceId": "19814db2-42f7-4788-9b51-b2001bf17953",
    "data": [
        {
            "s": "TSLA.US",
            "respList": [
                {
                    "t": "1751372340",
                    "h": "298.620",
                    "o": "298.439",
                    "l": "298.100",
                    "c": "298.310",
                    "v": "24329",
                    "vw": "7259092.235",
                    "pc": "-0.02%",
                    "pca": "-0.070"
                }
            ]
        }
    ]
}
```

| 字段名        | 类型     | 描述           | 示例值       |
| ---------- | ------ | ------------ | --------- |
| `s`        | String | 标的代码         | `TSLA.US` |
| `respList` | Array  | K 线列表，时间从大到小 |           |

#### respList

| 字段名   | 类型     | 描述                   | 示例值           |
| ----- | ------ | -------------------- | ------------- |
| `t`   | String | 秒时间戳                 | `1751372340`  |
| `h`   | String | 最高价                  | `298.620`     |
| `o`   | String | 开盘价                  | `298.439`     |
| `l`   | String | 最低价                  | `298.100`     |
| `c`   | String | 收盘价                  | `298.310`     |
| `v`   | String | 成交量                  | `24329`       |
| `vw`  | String | **成交额**（不是均价 / VWAP） | `7259092.235` |
| `pc`  | String | 涨跌幅                  | `-0.02%`      |
| `pca` | String | 涨跌额                  | `-0.070`      |
