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

# 获取余额历史

> 账户余额的每日演变,用于仪表盘图表:每个资产一条序列(每日收盘可用余额,无流水的日期沿用前值),外加一条按各日历史参考价对 BTC/GOLD 估值的 USD 汇总序列。包含期间总流入/流出及当前快照(可用 + 冻结),前端可据此渲染 Mercury 风格的余额卡片及其百分比变化。序列跟踪**可用**余额(冻结没有历史);`current` 携带今日各资产的 `held`。在历史价格存在之前用今日现价估值的日期会在 `spot_priced_dates` 中披露——绝不虚构数值。

`assets` 映射还包含银行账户镜像(`BANK_USD`、`BANK_EUR`),以其自身货币(2 位小数)作为独立序列提供。它们**不**计入 `total_usd` 汇总——该汇总仅覆盖运营余额(USDT、USDC、BTC、GOLD)。




## OpenAPI

````yaml /openapi.zh.yaml get /v1/balances/history
openapi: 3.1.0
info:
  title: CBPay API
  version: '1.89'
  description: >
    CBPay 是一个多币种支付平台:覆盖拉美的法币付款(payout)与收款(payin)、内部转账、链上充值与提现,以及 KYC
    筛查。每个账户持有四个相互独立的虚拟余额——USDT(运营货币)、USDC、BTC 和 GOLD(纯金克数)——它们绝不混合也不会自动兑换。

    payout 和服务费可从四个余额中的任意一个支付:

    用 `PUT /v1/settlement` 设置默认值,或在单笔 payout 中用

    `settlement_asset` 覆盖。


    所有金额均为十进制字符串,遵循各货币的精度(USDT/USDC/GOLD 为 6 位小数,BTC 为 8 位)。错误始终返回

    `{"error": "<code>", "message": "<detail>"}`。
servers:
  - url: https://api.qbank.cl/platform
    description: Live（生产环境，真实资金）
  - url: https://cryptobank.qbank.cl/platform
    description: Test（沙盒，模拟资金 — pk_test_ 密钥）
security:
  - bearerAuth: []
tags:
  - name: 凭证
    description: >-
      每笔操作的品牌化 PDF 凭证,附带公开的签名 QR 真伪校验、每个响应/webhook 中的
      receipt_url,以及最终状态时的自动邮件发送。
  - name: 身份认证
    description: 注册与登录账户成员。会话有效期 24 小时。
  - name: 账户
    description: 调用账户的档案、成员与 API key。
  - name: 余额
    description: 余额、流水历史与外汇汇率。
  - name: 付款(Payouts)
    description: 从你选择的结算余额扣款的法币派发(默认 USDT)。
  - name: 收款(Payins)
    description: 入账到 USDT 余额的法币充值。
  - name: 转账
  - name: 联系人
  - name: 兑换(Swaps)
    description: CBPay 账户之间的免费内部转账(个人或企业,任意组合)。
  - name: 加密货币
    description: 链上充值与提现(TRON、Ethereum 和 Bitcoin)。
  - name: 隔离钱包
    description: 拥有自身余额的链上钱包(企业不限数量;个人每个网络+资产组合 1 个)——创建、导入、发送、导出私钥与自动转发。余额存在于链上,从不进入账本。
  - name: QR Crypto POS
    description: >-
      面向拥有实体 POS 终端的处理商（企业账户）的定额加密货币二维码收款：已验证商户、每笔收款专属地址 +
      二维码、支付早期检测、按商户对账，以及经加密货币提现通道的退款。
  - name: KYC / KYB
  - name: AML 筛查
    description: 身份验证:个人 KYC、企业 KYB,含 AML 筛查、重新筛查与持续监控。
  - name: 钱包筛查
    description: 区块链地址的 AML 风险评估(制裁、非法资金暴露),按次收费;另附提现与充值的免费自动防护。
  - name: 分析
  - name: Webhooks
    description: 接收签名事件通知的订阅。
  - name: 状态
    description: 服务可用性。
  - name: 银行服务
    description: 真实银行账户:通过国际银行通道接收、持有与发送资金。
  - name: 卡片
    description: 以 Just-In-Time 方式从账户 USDT 余额消费的虚拟卡与实体卡,支持按卡设置消费限额。
  - name: 安全(OTP)
    description: >-
      通过 SMS/WhatsApp/email 发送的一次性验证码,保护敏感操作;并提供自助 2FA 偏好设置。仅适用于用户会话——API key
      豁免。
  - name: 通行密钥
    description: >-
      通过 WebAuthn 使用设备生物识别(Face ID、Touch ID、Windows
      Hello、安全密钥)的无密码登录、带备份码的验证器应用(TOTP),以及会话/设备管理。
  - name: 社交登录
    description: >-
      通过令牌交换以 Google、Apple、Microsoft 和 Facebook 实现无密码注册与登录。前端获取提供方凭证;API 验证后签发
      CBPay 会话。
paths:
  /v1/balances/history:
    get:
      tags:
        - 余额
      summary: 获取余额历史
      description: >
        账户余额的每日演变,用于仪表盘图表:每个资产一条序列(每日收盘可用余额,无流水的日期沿用前值),外加一条按各日历史参考价对 BTC/GOLD
        估值的 USD 汇总序列。包含期间总流入/流出及当前快照(可用 + 冻结),前端可据此渲染 Mercury
        风格的余额卡片及其百分比变化。序列跟踪**可用**余额(冻结没有历史);`current` 携带今日各资产的
        `held`。在历史价格存在之前用今日现价估值的日期会在 `spot_priced_dates` 中披露——绝不虚构数值。


        `assets` 映射还包含银行账户镜像(`BANK_USD`、`BANK_EUR`),以其自身货币(2
        位小数)作为独立序列提供。它们**不**计入 `total_usd` 汇总——该汇总仅覆盖运营余额(USDT、USDC、BTC、GOLD)。
      operationId: getBalancesHistory
      parameters:
        - name: from
          in: query
          required: true
          schema:
            type: string
            format: date
          description: 开始日期(YYYY-MM-DD,UTC,含当日)。
        - name: to
          in: query
          required: true
          schema:
            type: string
            format: date
          description: 结束日期(YYYY-MM-DD,UTC,含当日)。最大范围 366 天。
      responses:
        '200':
          description: 每个资产的每日余额序列,外加 USD 汇总。
          content:
            application/json:
              schema:
                type: object
                properties:
                  account_id:
                    type: string
                  from:
                    type: string
                  to:
                    type: string
                  granularity:
                    type: string
                    example: day
                  timezone:
                    type: string
                    example: UTC
                  assets:
                    type: object
                    description: >-
                      每个资产一条每日收盘余额序列。包含运营余额(USDT、USDC、BTC、GOLD)以及以自身货币计的银行账户镜像(BANK_USD、BANK_EUR);银行序列不计入
                      `total_usd`。
                    additionalProperties:
                      type: object
                      properties:
                        series:
                          type: array
                          items:
                            type: object
                            properties:
                              date:
                                type: string
                                example: '2026-07-10'
                              balance:
                                type: string
                                example: '125.430000'
                        first:
                          type: string
                        last:
                          type: string
                        change_pct:
                          type: string
                          nullable: true
                          description: 首→末的带符号百分比变化(序列从零开始时为 null)。
                  total_usd:
                    type: object
                    description: 所有余额按日汇总的 USD 价值。
                    properties:
                      series:
                        type: array
                        items:
                          type: object
                          properties:
                            date:
                              type: string
                            balance_usd:
                              type: string
                      first:
                        type: string
                      last:
                        type: string
                      change_pct:
                        type: string
                        nullable: true
                      spot_priced_dates:
                        type: array
                        items:
                          type: string
                        description: 因不存在历史价格而按今日现价估值的日期。
                      unpriced_assets:
                        type: array
                        items:
                          type: string
                        description: 因缺少任何价格而被排除在 USD 汇总之外的资产。
                  period:
                    type: object
                    description: 期间的总流入/流出(USD)。
                    properties:
                      in_usd:
                        type: string
                      out_usd:
                        type: string
                      net_usd:
                        type: string
                  current:
                    type: object
                    description: 当前快照(可用 + 冻结,按现价估值)。
                    properties:
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            asset:
                              type: string
                            available:
                              type: string
                            held:
                              type: string
                            usd_estimate:
                              type: string
                              nullable: true
                      net_worth_usd_estimate:
                        type: string
                        nullable: true
              example:
                account_id: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
                from: '2026-06-12'
                to: '2026-07-11'
                granularity: day
                timezone: UTC
                assets:
                  USDT:
                    series:
                      - date: '2026-06-12'
                        balance: '100.000000'
                      - date: '2026-06-13'
                        balance: '100.000000'
                      - date: '2026-07-11'
                        balance: '125.430000'
                    first: '100.000000'
                    last: '125.430000'
                    change_pct: '25.43'
                  BTC:
                    series:
                      - date: '2026-06-12'
                        balance: '0.00060000'
                      - date: '2026-07-11'
                        balance: '0.00060000'
                    first: '0.00060000'
                    last: '0.00060000'
                    change_pct: '0.00'
                  BANK_USD:
                    series:
                      - date: '2026-06-12'
                        balance: '1500.00'
                      - date: '2026-07-11'
                        balance: '1725.50'
                    first: '1500.00'
                    last: '1725.50'
                    change_pct: '15.03'
                total_usd:
                  series:
                    - date: '2026-06-12'
                      balance_usd: '163.73'
                    - date: '2026-07-11'
                      balance_usd: '191.34'
                  first: '163.73'
                  last: '191.34'
                  change_pct: '16.86'
                  spot_priced_dates: []
                  unpriced_assets: []
                period:
                  in_usd: '280.20'
                  out_usd: '254.77'
                  net_usd: '25.43'
                current:
                  items:
                    - asset: USDT
                      available: '125.430000'
                      held: '10.000000'
                      usd_estimate: '135.43'
                    - asset: USDC
                      available: '0.000000'
                      held: '0.000000'
                      usd_estimate: '0.00'
                    - asset: BTC
                      available: '0.00060000'
                      held: '0.00000000'
                      usd_estimate: '65.91'
                    - asset: GOLD
                      available: '0.000000'
                      held: '0.000000'
                      usd_estimate: '0.00'
                  net_worth_usd_estimate: '201.34'
        '400':
          description: 日期范围缺失或无效(`invalid_range`)。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: invalid_range
                message: from and to are required (YYYY-MM-DD)
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/AccountRequired'
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: 机器可读的错误代码(snake_case)。
          example: insufficient_funds
        message:
          type: string
          description: 人类可读的说明。
  responses:
    Unauthorized:
      description: 凭证缺失或无效(`unauthorized`)。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: unauthorized
            message: invalid or missing credentials
    AccountRequired:
      description: 此端点需要账户凭证(`account_required`)。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: account_required
            message: this endpoint requires an account credential
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |
        会话 JWT(来自注册/登录)或 API key(`pk_...`)。
        也接受 `X-API-Key: <token>` 作为替代请求头。

````