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

# 单产品k线

### 接口说明

该接口可用来查询历史k线，但每次只能查询一个产品。

```http theme={null}
GET /v1/kline/{queryData}
```

**美股、港股、A股、大盘数据请求示例：**

`https://quote.alltick.co/quote-stock-b-api/v1/kline/{queryData}`

**外汇、贵金属、加密货币、原油、CFD指数、商品请求示例：**

`https://quote.alltick.co/quote-b-api/v1/kline/{queryData}`

### 请求参数

| 参数 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `X-API-Key` | string | 是 | 身份认证令牌 |
| `queryData` | string | 是 | 请求内容 |

#### queryData

```json theme={null}
{
  "trace": "3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806",
  "data": {
    "code": "857.HK",
    "kline_type": 1,
    "kline_timestamp_end": 0,
    "query_kline_num": 2,
    "adjust_type": 0
  }
}
```

| 名称 | 类型 | 必选 | 说明 |
| - | - | - | - |
| `trace` | string | 是 | 追踪码，用来查询日志使用，请保证每次请求时唯一 |
| `data` | object | 是 | 请求数据 |
| `code` | string | 是 | 产品代码，code值大小写要与产品列表保持一致 |
| `kline_type` | integer | 是 | 1=1分钟K，2=5分钟K，3=15分钟K，4=30分钟K，5=小时K，6=2小时K，7=4小时K，8=日K，9=周K，10=月K；股票不支持2小时K、4小时K |
| `kline_timestamp_end` | integer | 是 | 传0表示从当前最新交易日往前查询；外汇、贵金属、加密货币支持传时间戳，股票类不支持 |
| `query_kline_num` | integer | 是 | 每次最大请求500根；查询昨日收盘价时传2并将 `kline_type` 设为8 |
| `adjust_type` | integer | 是 | 股票复权类型：0=除权，1=前复权，目前仅支持0 |

### 返回示例

```json theme={null}
{
  "ret": 200,
  "msg": "ok",
  "trace": "3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806",
  "data": {
    "code": "857.HK",
    "kline_type": 1,
    "kline_list": [
      {
        "timestamp": "1677829200",
        "open_price": "136.421",
        "close_price": "136.412",
        "high_price": "136.422",
        "low_price": "136.407",
        "volume": "0",
        "turnover": "0"
      },
      {
        "timestamp": "1677829260",
        "open_price": "136.412",
        "close_price": "136.401",
        "high_price": "136.415",
        "low_price": "136.397",
        "volume": "0",
        "turnover": "0"
      }
    ]
  }
}
```

### 返回字段

| 名称 | 类型 | 说明 |
| - | - | - |
| `ret` | integer | 返回code |
| `msg` | string | 返回消息 |
| `trace` | string | 请求的trace |
| `code` | string | 产品代码 |
| `kline_type` | integer | K线类型 |
| `kline_list` | array | K线列表 |
| `timestamp` | string | K线时间戳 |
| `open_price` | string | 开盘价 |
| `close_price` | string | 收盘价；交易时段最新一根K线也是最新成交价，休市期间是收盘价 |
| `high_price` | string | 最高价 |
| `low_price` | string | 最低价 |
| `volume` | string | 成交数量 |
| `turnover` | string | 成交金额 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.