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

# K 线数据

> 获取单只股票的 K 线数据，支持分钟线、日线、周线、月线

获取单只股票的 K 线数据，通过 `kline_type` 参数支持多种周期：1分钟、5分钟、15分钟、30分钟、60分钟、日线、周线、月线。

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://api.reportify.cn/v1/quant/quotes/kline?symbol=000001&kline_type=1D&market=cn" \
    -H "Authorization: Bearer <token>"
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      "https://api.reportify.cn/v1/quant/quotes/kline",
      headers={"Authorization": "Bearer <token>"},
      params={
          "symbol": "000001",
          "kline_type": "1D",
          "market": "cn",
          "start_datetime": "2026-01-01 00:00:00",
          "end_datetime": "2026-01-31 00:00:00"
      }
  )
  print(response.json())
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch('https://api.reportify.cn/v1/quant/quotes/kline?symbol=000001&kline_type=1D&market=cn', {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer <token>'
    }
  });
  const data = await response.json();
  ```
</CodeGroup>

## 请求参数

<ParamField query="symbol" type="string" required>
  股票代码
</ParamField>

<ParamField query="kline_type" type="string" default="1D">
  K 线周期类型：

  * `1M` - 1 分钟线
  * `5M` - 5 分钟线
  * `15M` - 15 分钟线
  * `30M` - 30 分钟线
  * `60M` - 60 分钟线
  * `1D` - 日线（默认）
  * `1W` - 周线
  * `1MO` - 月线
</ParamField>

<ParamField query="market" type="string" default="cn">
  股票市场：`cn`（A股）, `hk`（港股）, `us`（美股）
</ParamField>

<ParamField query="stock_type" type="string" default="stock">
  股票类型：`stock`（股票）, `etf`（ETF）, `index`（指数）, `sw`（申万指数）
</ParamField>

<ParamField query="start_datetime" type="string">
  开始时间，格式：`YYYY-MM-DD HH:MM:SS`（可选，不传时按 kline\_type 自动推算）
</ParamField>

<ParamField query="end_datetime" type="string">
  结束时间，格式：`YYYY-MM-DD HH:MM:SS`（可选，默认当前时间）
</ParamField>

## 默认时间范围

不传 `start_datetime` 时，根据 `kline_type` 自动向前推算：

| kline\_type   | 默认范围  |
| ------------- | ----- |
| `1M`          | 1 天   |
| `5M` / `15M`  | 3 天   |
| `30M` / `60M` | 5 天   |
| `1D`          | 30 天  |
| `1W`          | 180 天 |
| `1MO`         | 365 天 |

## 响应参数

<ResponseField name="datas" type="array">
  K 线数据列表

  <Expandable title="数据字段">
    <ResponseField name="market" type="string">
      股票市场（cn / hk / us）
    </ResponseField>

    <ResponseField name="date" type="string">
      日期时间（分钟线格式：`YYYY-MM-DD HH:MM:SS`，日线/周线/月线格式：`YYYY-MM-DD`）
    </ResponseField>

    <ResponseField name="symbol" type="string">
      股票代码
    </ResponseField>

    <ResponseField name="open" type="number">
      开盘价
    </ResponseField>

    <ResponseField name="high" type="number">
      最高价
    </ResponseField>

    <ResponseField name="low" type="number">
      最低价
    </ResponseField>

    <ResponseField name="close" type="number">
      收盘价
    </ResponseField>

    <ResponseField name="volume" type="integer">
      成交量（股）
    </ResponseField>

    <ResponseField name="amount" type="number">
      成交额（元）
    </ResponseField>

    <ResponseField name="chg_percent" type="number">
      涨跌幅（%）
    </ResponseField>

    <ResponseField name="turnover_rate" type="number">
      换手率
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="metadata" type="object">
  查询元数据，包含 `symbol`, `kline_type`, `start_datetime`, `end_datetime`, `count`
</ResponseField>

## 响应示例

```json theme={null}
{
  "datas": [
    {
      "market": "cn",
      "date": "2026-04-01",
      "symbol": "000001",
      "open": 10.98,
      "high": 11.02,
      "low": 10.93,
      "close": 11.0,
      "volume": 17744106,
      "amount": 194464864.8,
      "chg_percent": 0.1821,
      "turnover_rate": 0.0004
    },
    {
      "market": "cn",
      "date": "2026-04-02",
      "symbol": "000001",
      "open": 11.0,
      "high": 11.15,
      "low": 10.96,
      "close": 11.08,
      "volume": 21356890,
      "amount": 236512345.6,
      "chg_percent": 0.7273,
      "turnover_rate": 0.0005
    }
  ],
  "metadata": {
    "symbol": "000001",
    "kline_type": "1D",
    "start_datetime": "2026-04-01 00:00:00",
    "end_datetime": "2026-04-30 00:00:00",
    "count": 2
  }
}
```

## 使用示例

### 获取日线数据（默认）

```python theme={null}
import requests

response = requests.get(
    "https://api.reportify.cn/v1/quant/quotes/kline",
    headers={"Authorization": "Bearer <token>"},
    params={
        "symbol": "000001",
        "kline_type": "1D",
        "start_datetime": "2026-01-01 00:00:00",
        "end_datetime": "2026-03-31 00:00:00"
    }
)
data = response.json()
for row in data["datas"]:
    print(f"{row['date']}: 收{row['close']} 量{row['volume']}")
```

### 获取 5 分钟 K 线

```python theme={null}
response = requests.get(
    "https://api.reportify.cn/v1/quant/quotes/kline",
    headers={"Authorization": "Bearer <token>"},
    params={
        "symbol": "000001",
        "kline_type": "5M",
        "start_datetime": "2026-04-09 09:30:00",
        "end_datetime": "2026-04-09 15:00:00"
    }
)
```

### 获取周线数据

```python theme={null}
response = requests.get(
    "https://api.reportify.cn/v1/quant/quotes/kline",
    headers={"Authorization": "Bearer <token>"},
    params={
        "symbol": "600519",
        "kline_type": "1W",
        "market": "cn"
    }
)
```

### 获取 ETF 数据

```python theme={null}
response = requests.get(
    "https://api.reportify.cn/v1/quant/quotes/kline",
    headers={"Authorization": "Bearer <token>"},
    params={
        "symbol": "510300",
        "kline_type": "1D",
        "stock_type": "etf"
    }
)
```


## OpenAPI

````yaml GET /v1/quant/quotes/kline
openapi: 3.1.0
info:
  title: Reportify API
  version: 1.0.0
  description: API documentation for Reportify's document management and search services.
servers:
  - url: https://api.reportify.cn
    description: Production server
security:
  - BearerAuth: []
paths:
  /v1/quant/quotes/kline:
    get:
      tags:
        - openapi-quant
      summary: Get kline data
      description: >
        Get kline data for a single symbol. Supports all periods via kline_type
        parameter.


        - **symbol**: Stock code (required)

        - **kline_type**: Kline period (1M/5M/15M/30M/60M/1D/1W/1MO), default:
        1D

        - **market**: Stock market (cn, hk, us), default: cn

        - **stock_type**: Stock type (stock, etf, index, sw), default: stock

        - **start_datetime**: Start datetime (optional, auto-inferred if
        omitted)

        - **end_datetime**: End datetime (optional, default: now)
      operationId: quote_kline
      parameters:
        - name: symbol
          in: query
          required: true
          schema:
            type: string
            title: Symbol
          description: Stock code (e.g., 600519, 00700, AAPL)
          example: '000001'
        - name: kline_type
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/KLineType'
            default: 1D
          description: Kline period type
        - name: market
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/StockMarket'
            default: cn
        - name: stock_type
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/StockType'
            default: stock
        - name: start_datetime
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                format: date-time
              - type: 'null'
            title: Start Datetime
          description: Start datetime (YYYY-MM-DD HH:MM:SS)
          example: '2026-04-01 00:00:00'
        - name: end_datetime
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                format: date-time
              - type: 'null'
            title: End Datetime
          description: End datetime (YYYY-MM-DD HH:MM:SS)
          example: '2026-04-28 00:00:00'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KlineOutput'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    KLineType:
      type: string
      enum:
        - 1M
        - 5M
        - 15M
        - 30M
        - 60M
        - 1D
        - 1W
        - 1MO
      title: KLineType
      description: Kline period type
    StockMarket:
      type: string
      enum:
        - cn
        - hk
        - us
        - global
      title: StockMarket
      description: Stock market identifier
    StockType:
      type: string
      enum:
        - stock
        - etf
        - index
        - sw
      title: StockType
      description: Stock type identifier
    KlineOutput:
      type: object
      required:
        - datas
        - metadata
      properties:
        datas:
          type: array
          title: Datas
          description: Kline data list
          items:
            type: object
            additionalProperties: true
            description: |
              Items contain:
              - date or datetime (string)
              - symbol (string)
              - open (number)
              - high (number)
              - low (number)
              - close (number)
              - volume (integer)
        metadata:
          type: object
          title: Metadata
          description: >-
            Query metadata (symbol, kline_type, start_datetime, end_datetime,
            count)
          additionalProperties: true
      title: KlineOutput
      description: Kline data response.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Enter your Bearer token

````