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

# 获取K线数据

> 获取单个标的的OHLCV K线数据。支持日线、周线、月线和分钟级别。数据以列式格式返回，传输效率高。



## OpenAPI

````yaml /zh-Hans/api-reference/openapi.json get /v1/klines
openapi: 3.1.0
info:
  contact:
    email: support@tickflow.org
  description: 提供中国A股、美股、港股的实时和历史行情数据接口
  title: MarketData API
  version: 1.0.0
servers:
  - url: https://api.alphafeed.org
security:
  - ApiKeyHeader: []
  - ApiKeyQuery: []
tags:
  - description: 历史K线（OHLCV）数据
    name: K线数据
  - description: 实时报价和市场深度
    name: 实时行情
  - description: 日内分钟级别数据
    name: 日内分时
  - description: 标的元数据
    name: 基础信息
paths:
  /v1/klines:
    get:
      tags:
        - K线数据
      summary: 获取K线数据
      description: 获取单个标的的OHLCV K线数据。支持日线、周线、月线和分钟级别。数据以列式格式返回，传输效率高。
      operationId: getKlines
      parameters:
        - description: 标的代码（如 `600000.SH`、`AAPL.US`、`00700.HK`）
          example: 600000.SH
          in: query
          name: symbol
          required: true
          schema:
            type: string
        - description: K线周期。分钟级（1m/5m/15m/30m/60m）需要分钟K线权限，日/周/月/季/年需要日K线权限。
          in: query
          name: period
          schema:
            $ref: '#/components/schemas/Period'
        - description: 最大返回条数
          in: query
          name: count
          schema:
            default: 100
            maximum: 10000
            type: integer
        - description: 起始时间戳（毫秒，含）
          in: query
          name: start_time
          schema:
            format: int64
            type: integer
        - description: 结束时间戳（毫秒，含）
          in: query
          name: end_time
          schema:
            format: int64
            type: integer
        - description: >-
            复权类型：`none`（不复权）、`forward`（前复权）、`backward`（后复权）、`forward_additive`（前复权-差值）、`backward_additive`（后复权-差值）
          in: query
          name: adjust
          schema:
            $ref: '#/components/schemas/AdjustType'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KlineResponse'
          description: K线数据
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    Period:
      default: 1d
      description: K线周期
      enum:
        - 1m
        - 5m
        - 15m
        - 30m
        - 60m
        - 1d
        - 1w
        - 1M
        - 1Q
        - 1Y
      type: string
    AdjustType:
      default: forward
      description: 复权类型
      enum:
        - none
        - forward
        - backward
        - forward_additive
        - backward_additive
      type: string
    KlineResponse:
      properties:
        data:
          $ref: '#/components/schemas/CompactKlineData'
      required:
        - data
      type: object
    CompactKlineData:
      description: 列式OHLCV数据，传输效率高。每个数组长度相同，相同下标对应同一根K线。
      properties:
        amount:
          description: 成交额
          items:
            type: number
          type: array
        close:
          description: 收盘价
          items:
            type: number
          type: array
        high:
          description: 最高价
          items:
            type: number
          type: array
        low:
          description: 最低价
          items:
            type: number
          type: array
        open:
          description: 开盘价
          items:
            type: number
          type: array
        prev_close:
          description: 前收盘价（部分接口返回）
          items:
            type: number
          type: array
        timestamp:
          description: 时间戳（毫秒）
          items:
            format: int64
            type: integer
          type: array
        volume:
          description: 成交量
          items:
            format: int64
            type: integer
          type: array
      required:
        - timestamp
        - open
        - high
        - low
        - close
        - volume
        - amount
      type: object
    ErrorResponse:
      description: 错误响应
      properties:
        code:
          description: HTTP 状态码
          type: integer
        message:
          description: 错误描述
          type: string
      required:
        - code
        - message
      type: object
    RateLimitResponse:
      description: 限流响应
      properties:
        code:
          example: 429
          type: integer
        message:
          description: 限流说明
          type: string
        retry_after_ms:
          description: 建议等待时间（毫秒）
          type: integer
      required:
        - code
        - message
        - retry_after_ms
      type: object
  responses:
    Unauthorized:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: API Key 无效或缺失
    Forbidden:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: 当前套餐无此功能/市场权限
    RateLimited:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitResponse'
      description: 请求频率超限
  securitySchemes:
    ApiKeyHeader:
      description: 在请求头 X-API-Key 中传递 API Key
      in: header
      name: X-API-Key
      type: apiKey
    ApiKeyQuery:
      description: 在 URL 查询参数 api_key 中传递 API Key
      in: query
      name: api_key
      type: apiKey

````