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

# 查询流量消耗

> 查询流量消耗



## OpenAPI

````yaml POST /account/queryTrafficUsage
openapi: 3.0.1
info:
  title: OpenAPI Plant Store
  description: >-
    A sample API that uses a plant store as an example to demonstrate features
    in the OpenAPI specification
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://apiv1.cakeip.com/openapi
security: []
paths:
  /account/queryTrafficUsage:
    post:
      description: 查询流量消耗
      requestBody:
        description: 查询流量消耗请求
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryTrafficUsage'
        required: true
      responses:
        '200':
          description: 流量消耗查询响应
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrafficUsageResponse'
        '400':
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    QueryTrafficUsage:
      type: object
      description: 查询流量消耗请求参数
      properties:
        appKey:
          type: string
          description: AppKey密钥
        type:
          type: string
          description: 查询粒度：day=按天统计，5min=按5分钟统计
          enum:
            - day
            - 5min
          example: day
        startDay:
          type: string
          format: date
          description: 开始日期（格式：YYYY-MM-DD）
          example: '2024-01-01'
        endDay:
          type: string
          format: date
          description: 结束日期（格式：YYYY-MM-DD）
          example: '2024-01-02'
        provider:
          type: integer
          format: int32
          description: 池子类型：1=优选池（默认）。2=标准池已下架，但保留以查询历史数据
          enum:
            - 1
            - 2
          default: 1
          example: 1
      required:
        - appKey
        - type
        - startDay
        - endDay
    TrafficUsageResponse:
      type: object
      description: >-
        流量消耗查询响应。data为数组格式，每条记录包含时间和流量值。时间格式根据查询粒度不同：type=day时为'YYYY-MM-DD'，type=5min时为'YYYY-MM-DD
        HH:mm:ss'
      properties:
        code:
          default: 0
          description: 状态码，0为操作成功
          type: integer
          format: int32
          example: 0
          enum:
            - 0
            - -1
        msg:
          description: 响应消息
          type: string
          example: 查询成功
        data:
          description: 流量使用记录列表
          type: array
          items:
            type: object
            properties:
              time:
                type: string
                description: >-
                  时间点。type=day时格式为'YYYY-MM-DD'，type=5min时格式为'YYYY-MM-DD
                  HH:mm:ss'
                example: '2024-01-01'
              traffic:
                type: number
                format: float
                description: 该时间段流量消耗（单位：MB）
                example: 100.5
          example:
            - time: '2024-01-01'
              traffic: 100.5
            - time: '2024-01-02'
              traffic: 200.3
        total:
          type: integer
          format: int32
          description: 记录数
          example: 2
        sum:
          type: number
          format: float
          description: 总流量消耗（单位：MB）
          example: 300.8
      required:
        - code
        - msg
        - data
        - total
        - sum
    Error:
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
      required:
        - error
        - message

````