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

# 银行账户余额 API：已记账与可用余额

> Didit 的获取账户余额端点返回账户的分类余额及其参考日期。

Didit 的“获取账户余额”endpoint 返回账户的分类余额及其参考日期。
`type` 取值为 `booked`、`available` 或 `expected`。
读取操作从不计费。


## OpenAPI

````yaml zh/openapi-25.json GET /v3/bank/accounts/{account_id}/balances/
openapi: 3.0.0
info:
  version: 3.0.0
  title: Didit Verification API
  description: 身份验证 API。使用 x-api-key 请求头进行身份验证。
servers:
  - url: https://verification.didit.me
security: []
tags:
  - name: Bank Data
    description: >-
      银行数据服务涵盖银行链接、连接、账户、余额、交易、机构和覆盖范围。银行数据可用于沙盒应用。在宣布开放生产访问之前，生产应用的调用将返回
      `404`。沙盒环境不收费。使用 API
      密钥进行的调用，需要具备银行数据权限（`bank-data`）的密钥：读取操作需要读取权限，会更改数据的操作需要写入权限。账户核验是例外，它需要会话的写入权限或完全访问权限，而不需要银行数据权限。银行数据不属于完全访问权限的一部分：完全访问密钥会被拒绝，调用返回
      `403
      bank_data_access_denied`，直到您创建具备该权限的密钥为止。原始银行数据（账户、余额、交易以及变更流）同样会拒绝不携带 API
      密钥的请求。


      除账户核验外，`/v3/bank/` 下的每个拒绝响应都具有相同的 JSON
      结构（`code`、`message`、`request_id`、`field`、`next_action`、`retry_after`）。不是操作的路径、不是
      UUID 的 ID 或未知的子资源，对于所有方法都返回 `404 not_found`；任何意外错误都返回 `500 internal_error`
      及 `request_id`。在银行数据不可用时，每个操作都返回平台标准的 `404`，与访问未知路由时完全相同。
paths:
  /v3/bank/accounts/{account_id}/balances/:
    get:
      tags:
        - Bank Data
      summary: 获取账户余额
      description: >-
        返回账户的各类型余额及其参考日期。余额在每次同步时被替换。


        需要具有银行数据权限（`bank-data`）的 API
        密钥：此操作所需的权限为读取。拥有完全访问权限的密钥不包含该权限：创建密钥时必须单独授予，否则调用将返回 `403
        bank_data_access_denied`。沙盒应用仅凭密钥即可读取其测试银行数据。不带 API
        密钥的请求（客户端凭据）在访问原始数据时会被拒绝，并返回相同的 `403`。
      operationId: getBankAccountBalances
      parameters:
        - name: account_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: 账户 ID。
      responses:
        '200':
          description: 余额。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BankBalances'
              examples:
                Booked and available:
                  summary: 已入账和可用余额
                  value:
                    account_id: a71f0c2e-5d38-4b96-a1c4-3e9f8d2b7a10
                    balances:
                      - type: booked
                        iso_type: CLBD
                        amount: '18250.34'
                        currency: EUR
                        reference_date: '2026-11-20'
                        last_change_at: '2026-11-20T22:10:00Z'
                        credit_limit_included: false
                      - type: available
                        iso_type: ITAV
                        amount: '17990.34'
                        currency: EUR
                        reference_date: '2026-11-21'
                        last_change_at: '2026-11-21T11:58:00Z'
                        credit_limit_included: false
                    last_synced_at: '2026-11-21T12:04:40Z'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/BankDataAccessDenied'
        '404':
          description: 该资源在此应用和环境中不存在。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BankDataError'
              examples:
                Not found:
                  summary: 未找到
                  value:
                    code: not_found
                    message: The resource does not exist.
                    request_id: 3f6a1c8e-92b5-4d07-a1e3-8c4b7f0d2e59
                    field: null
                    next_action: null
                    retry_after: null
        '409':
          description: >-
            用户不再共享该账户（`access_removed`），或连接已被删除，或其数据已无法读取（`connection_not_active`）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BankDataError'
              examples:
                Access removed:
                  summary: 访问权限已移除
                  value:
                    code: access_removed
                    message: The person no longer shares this account.
                    request_id: 3f6a1c8e-92b5-4d07-a1e3-8c4b7f0d2e59
                    field: null
                    next_action: null
                    retry_after: null
        '429':
          $ref: '#/components/responses/RateLimitedRead'
        '500':
          $ref: '#/components/responses/BankDataInternalError'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: >-
            curl
            'https://verification.didit.me/v3/bank/accounts/a71f0c2e-5d38-4b96-a1c4-3e9f8d2b7a10/balances/'
            \
              -H 'x-api-key: YOUR_API_KEY'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.bank.get_balances(
                "11111111-2222-3333-4444-555555555555",
            )
            print(result)
        - lang: javascript
          label: Node.js
          source: >-
            import Didit from "@didit-protocol/sdk-node";


            // Reads DIDIT_API_KEY.

            const didit = new Didit();


            const result = await
            didit.bank.getBalances("11111111-2222-3333-4444-555555555555");

            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresult, err := client.Bank.GetBalances(ctx, \"11111111-2222-3333-4444-555555555555\")\nif err != nil {\n\tlog.Fatal(err)\n}\nfmt.Printf(\"%+v\\n\", result)"
        - lang: java
          label: Java
          source: >-
            import me.didit.Didit;


            // Reads DIDIT_API_KEY.

            Didit client = new Didit();


            var result =
            client.bank().getBalances("11111111-2222-3333-4444-555555555555");

            System.out.println(result);
        - lang: php
          label: PHP
          source: >-
            <?php


            require 'vendor/autoload.php';


            use Didit\DiditClient;


            // Reads DIDIT_API_KEY.

            $didit = new DiditClient();


            $result =
            $didit->bank->getBalances('11111111-2222-3333-4444-555555555555');

            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: >-
            require "didit"


            # Reads DIDIT_API_KEY.

            didit = Didit::Client.new


            result =
            didit.bank.get_balances("11111111-2222-3333-4444-555555555555")

            puts result.to_h
        - lang: csharp
          label: .NET
          source: >-
            using System;

            using System.Text.Json;

            using Didit;


            // Reads DIDIT_API_KEY.

            using var client = new DiditClient();


            var result = await
            client.Bank.GetBalancesAsync("11111111-2222-3333-4444-555555555555");

            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  schemas:
    BankBalances:
      type: object
      description: 账户的各类余额。
      properties:
        account_id:
          type: string
          format: uuid
        balances:
          type: array
          items:
            $ref: '#/components/schemas/BankBalance'
        last_synced_at:
          type: string
          description: 余额最后一次从银行获取的时间。
          format: date-time
          nullable: true
      required:
        - account_id
        - balances
        - last_synced_at
    BankDataError:
      type: object
      description: 所有银行数据操作的错误响应体。每个字段始终存在。
      properties:
        code:
          type: string
          enum:
            - ongoing_access_not_available
            - segment_not_available
            - window_not_available
            - history_window_ambiguous
            - redirect_url_not_registered
            - link_origin_not_allowed
            - bank_data_access_denied
            - connection_not_active
            - consent_expired
            - renewal_not_needed
            - renewal_window_expired
            - access_removed
            - refresh_limit_reached
            - cursor_expired
            - page_expired
            - invalid_cursor
            - page_token_mismatch
            - contract_rate_missing
            - insufficient_credits
            - invalid_request
            - not_found
            - internal_error
          description: 机器可读的错误代码。请据此分支处理，切勿依据 `message`。
        message:
          type: string
          description: 面向开发者的通俗说明。措辞可能变化，请勿解析。
        request_id:
          type: string
          description: 本次请求的标识符。联系支持团队时请提供此标识符。
        field:
          type: string
          description: 需要更正的请求字段（如果错误与某个字段有关）。否则为 `null`。
          nullable: true
        next_action:
          type: string
          enum:
            - retry_later
            - renew_connection
            - create_link
            - restart_from_cursor
            - restart_read
            - top_up_balance
            - enable_bank_data_access
            - contact_support
            - null
          description: 下一步应执行的操作，便于客户端无需猜测即可执行。没有标准的下一步时为 `null`。
          nullable: true
        retry_after:
          type: integer
          description: 重试前需等待的秒数。仅在触发速率限制和出现临时错误时设置，否则为 `null`。
          nullable: true
      required:
        - code
        - message
        - request_id
        - field
        - next_action
        - retry_after
      example:
        code: ongoing_access_not_available
        message: >-
          This bank cannot keep access open. Use access one_time or choose
          another bank.
        request_id: 3f6a1c8e-92b5-4d07-a1e3-8c4b7f0d2e59
        field: institution_id
        next_action: create_link
        retry_after: null
    BankBalance:
      type: object
      properties:
        type:
          type: string
          enum:
            - booked
            - available
            - expected
            - other
          description: >-
            `booked`、`available` 或 `expected`。`other` 为 Didit
            无法映射的银行余额类型：会被返回而不会被丢弃，`iso_type` 保存银行的原始代码。
        iso_type:
          type: string
          description: 银行自身的余额类型代码，按银行发送的原样返回（若银行提供 ISO 20022 代码，则使用该代码）；若银行未发送，则为 `null`。
          nullable: true
        amount:
          type: string
          description: 金额为十进制字符串。
          pattern: ^-?\d+(\.\d+)?$
        currency:
          type: string
          pattern: ^[A-Z]{3}$
          description: ISO 4217 货币代码。
        reference_date:
          type: string
          format: date
          nullable: true
        last_change_at:
          type: string
          format: date-time
          nullable: true
        credit_limit_included:
          type: boolean
          nullable: true
          description: 银行明确提供时，是否包含透支额度。
      required:
        - type
        - iso_type
        - amount
        - currency
        - reference_date
        - last_change_at
        - credit_limit_included
    RateLimitBudgetError:
      type: object
      description: 仅在速率限制中间件预算拒绝时返回。其他 429 错误（包括幂等性冲突和端点特定上限）不保证返回这些元数据字段。
      required:
        - detail
        - reference
        - limit
        - remaining
        - reset
        - window_seconds
      properties:
        detail:
          type: string
          description: 已有的可读预算拒绝信息。
        reference:
          type: string
          pattern: ^RL-[0-9a-f]{32}$
          description: 不透明的支持参考编号：RL- 后跟 32 个小写 UUID 十六进制字符。
        limit:
          type: integer
          description: 超出限额的作用域对应的预算；与 X-RateLimit-Limit 相同。
        remaining:
          type: integer
          minimum: 0
          description: 剩余额度，下限为零；与 X-RateLimit-Remaining 相同。
        reset:
          type: integer
          format: int64
          description: 窗口重置时间，以 Unix 秒表示；与 X-RateLimit-Reset 相同。
        window_seconds:
          type: integer
          description: 固定窗口时长（秒），不是剩余等待时间。重试前请遵循 Retry-After。
      example:
        detail: >-
          Write request rate limit exceeded. You can make up to 300 requests per
          minute.
        reference: RL-00000000000040008000000000000001
        limit: 300
        remaining: 0
        reset: 1794358860
        window_seconds: 60
  responses:
    Unauthorized:
      description: 未授权
      content:
        application/json:
          examples:
            Invalid API Key:
              summary: API 密钥无效
              value:
                detail: Invalid API Key.
    BankDataAccessDenied:
      description: >-
        API 密钥不具有银行数据权限（`bank-data`），或者，对于生产环境应用中的原始银行数据，应用设置“Bank data in the
        API”已关闭。银行数据不属于完全访问权限：完全访问权限的密钥、仅限其他资源的密钥，以及未使用 API
        密钥认证的请求（客户端凭证，访问原始数据时）均会被以此响应体拒绝，因此请创建密钥并显式授予该权限。此拒绝发生在任何查询之前，因此不能说明对象是否存在。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BankDataError'
          examples:
            Bank data not allowed:
              summary: 不允许访问银行数据
              value:
                code: bank_data_access_denied
                message: >-
                  Bank data calls need an API key that carries the Bank data
                  permission.
                request_id: 3f6a1c8e-92b5-4d07-a1e3-8c4b7f0d2e59
                field: null
                next_action: enable_bank_data_access
                retry_after: null
    RateLimitedRead:
      description: 中间件读取额度已超出。重试前请先遵守 Retry-After。
      headers:
        Retry-After:
          $ref: '#/components/headers/BudgetRetryAfter'
        X-RateLimit-Scope:
          $ref: '#/components/headers/BudgetXRateLimitScope'
        X-RateLimit-Limit:
          $ref: '#/components/headers/BudgetXRateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/BudgetXRateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/BudgetXRateLimitReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitBudgetError'
          example:
            detail: >-
              GET request rate limit exceeded. You can make up to 600 requests
              per minute.
            reference: RL-00000000000040008000000000000001
            limit: 600
            remaining: 0
            reset: 1794358860
            window_seconds: 60
    BankDataInternalError:
      description: >-
        Didit 端出现了问题。`/v3/bank/` 下的任何意外错误都以银行错误格式返回，绝不返回 HTML 页面：请将 `request_id`
        提供给支持团队。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BankDataError'
          examples:
            Internal error:
              summary: 意外错误
              value:
                code: internal_error
                message: >-
                  Something went wrong on our side. Quote the request_id to
                  support.
                request_id: 3f6a1c8e92b54d07a1e38c4b7f0d2e59
                field: null
                next_action: contact_support
                retry_after: null
  headers:
    BudgetRetryAfter:
      description: 需等待的秒数，向上取整到下一个时间窗口。出现在中间件预算拒绝响应中。
      schema:
        type: integer
    BudgetXRateLimitScope:
      description: 已超出预算的范围。出现在中间件预算拒绝响应中。
      schema:
        type: string
    BudgetXRateLimitLimit:
      description: 超出限额的作用域的预算；与请求体限制相同。出现在中间件预算拒绝响应中。
      schema:
        type: integer
    BudgetXRateLimitRemaining:
      description: 剩余额度，下限为零；与响应体中的 remaining 相同。仅出现在中间件额度拒绝的响应中。
      schema:
        type: integer
    BudgetXRateLimitReset:
      description: 以 Unix 秒表示的重置时间；与正文中的 reset 相同。出现在中间件预算拒绝响应中。
      schema:
        type: integer
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        您的应用 API 密钥，可在 Business Console 的开发者 -> API
        密钥中获取。主密钥拥有完全访问权限。命名密钥可以设置范围：可按资源设置无权限、只读或读写，可限定为部分工作流或已批准的会话，可限定为一组 IP
        地址，并可设置过期日期。401 表示密钥错误、已被撤销或已过期；403 表示未发送密钥、密钥无权访问该资源或执行该操作，或请求来自其 IP
        列表之外的地址；会话相关路由返回 404，表示该会话不在密钥的工作流或状态范围内。没有媒体访问权限的密钥会将图片、视频和 PDF 的 URL
        返回为 null；没有会话写入权限的密钥会将会话链接和令牌返回为 null。请参阅
        https://docs.didit.me/console/api-keys。

````

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