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

# 获取历史代币余额

> 获取钱包在过去某个时间戳、日期时间或槽位的特定代币或本地 SOL 余额。

每次请求花费 **100 个积分**。

## 请求参数

<ParamField body="wallet" type="string" required default="GQUtvPx89ZNCwmvQqFmH59bJcU8fW8siETpaxod7Aydz">
  Solana 钱包地址（base58 编码）
</ParamField>

<ParamField body="mint" type="string" required default="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v">
  代币发行地址。对于本地 SOL，请使用 `So11111111111111111111111111111111111111111`。
</ParamField>

<ParamField body="time" type="number" default="1750000000">
  Unix 时间戳（**秒**）。返回该时间的余额。请提供 `time`、`datetime` 或 `slot` 中的一个。
</ParamField>

<ParamField body="datetime" type="string">
  日期时间字符串。接受的格式：`2025-01-10`（UTC 午夜）、`2025-01-10 19:20:00`、
  `2025-01-10T19:20:00`（秒数可选），或包含明确时区的格式
  (`2025-01-10T19:20:00Z`, `...+02:00`)。**解释为 UTC ，除非包含明确时区。** 请提供 `time`、`datetime` 或 `slot` 中的一个。
</ParamField>

<ParamField body="slot" type="number">
  槽位号。返回该槽位的余额。准确且确定的。请提供 `time`、`datetime` 或 `slot` 中的一个。
</ParamField>


## OpenAPI

````yaml zh/openapi/wallet-api/openapi.yaml GET /v1/wallet/{wallet}/balance-at
openapi: 3.0.3
info:
  title: Wallet API
  description: |
    一个高性能的REST API，用于查询Solana钱包数据，包括余额、交易记录、转账和身份信息。

    ## 认证

    所有请求都需要通过以下方式传递API密钥：
    - 查询参数：`?api-key=YOUR_API_KEY`
    - 头：`X-Api-Key: YOUR_API_KEY`
  version: 1.0.0
  contact:
    name: API支持
    url: https://helius.dev
servers:
  - url: https://api.helius.xyz
    description: 生产服务器
security:
  - ApiKeyQuery: []
  - ApiKeyHeader: []
tags:
  - name: Identity
    description: 查找钱包身份和已知地址
  - name: Balances
    description: 查询代币和NFT余额
  - name: History
    description: 交易历史和余额变动
  - name: Transfers
    description: 代币转账活动
  - name: Funding
    description: 钱包资金信息
paths:
  /v1/wallet/{wallet}/balance-at:
    get:
      tags:
        - 余额
      summary: 获取历史余额
      description: >-
        检索钱包在过去某个时间点的特定代币（或本机SOL）的余额，可以通过Unix时间戳、日期时间字符串或插槽号指定。


        余额是从钱包的最近一笔包含该代币的交易中读取的，是所请求时间点**当时或之前**的交易后余额，定义上保持到钱包的下一个交易为止。这是一个精确的值，不是估计值。


        必须提供`time`、`datetime`或`slot`中的**一个**。没有明确时区的`datetime`值将被解释为**UTC**。要获得精确、确定的结果，请使用`slot`
        — 验证器报告的区块时间可能会偏移几秒钟。


        对于本机SOL，请将伪造币`So11111111111111111111111111111111111111111`作为`mint`传递。


        在请求点**没有匹配活动**的钱包并不是错误 — 端点返回`200`，并带有`balance: "0"`和`asOf: null`。


        `balance`和`balanceRaw`以**字符串**形式返回，以避免大值的精度损失。
      operationId: getWalletBalanceAt
      parameters:
        - $ref: '#/components/parameters/WalletAddress'
        - name: mint
          in: query
          required: true
          description: 代币铸币地址。对于本机SOL，使用`So11111111111111111111111111111111111111111`。
          schema:
            type: string
            default: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
          example: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
        - name: time
          in: query
          description: '**秒**为单位的Unix时间戳。返回此时间的余额。在`time`、`datetime`或`slot`中准确提供一个。'
          schema:
            type: integer
            default: 1750000000
            minimum: 0
          example: 1736536800
        - name: datetime
          in: query
          description: >
            日期时间字符串。接受的格式：`2025-01-10` (UTC午夜)，`2025-01-10 19:20:00`，

            `2025-01-10T19:20:00`（秒可选），或带显式时区

            (`2025-01-10T19:20:00Z`, `...+02:00`)。**如果没有明确的时区，会被解释为UTC。**
            在`time`、`datetime`或`slot`中准确提供一个。
          schema:
            type: string
          example: '2025-01-10 19:20:00'
        - name: slot
          in: query
          description: 插槽号。返回此插槽的余额。精确且确定。在`time`、`datetime`或`slot`中准确提供一个。
          schema:
            type: integer
            minimum: 0
          example: 313000000
      responses:
        '200':
          description: 成功检索历史余额
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BalanceAtResponse'
        '400':
          description: >-
            缺少`mint`；无效的mint；零个或多个`time`/`datetime`/`slot`；非整数`time`/`slot`；或无法解析的`datetime`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: 必须提供`time`、`datetime`或`slot`中的一个
                code: 400
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: 路径中无效的钱包地址
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
        '502':
          description: 上游RPC错误或超时。可使用指数退避重试。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: UPSTREAM_ERROR
                code: 502
                details: 上游RPC请求失败。请重试。
components:
  parameters:
    WalletAddress:
      name: wallet
      in: path
      required: true
      description: Solana 钱包地址（base58 编码）
      schema:
        type: string
        pattern: ^[1-9A-HJ-NP-Za-km-z]{32,44}$
        default: GQUtvPx89ZNCwmvQqFmH59bJcU8fW8siETpaxod7Aydz
      example: GQUtvPx89ZNCwmvQqFmH59bJcU8fW8siETpaxod7Aydz
  schemas:
    BalanceAtResponse:
      type: object
      properties:
        wallet:
          type: string
          description: 查询钱包地址的回显
          example: 5tzFkiKscXHK5ZXCGbXZxdw7gTjjD1mBwuoFbhUvuAi9
        mint:
          type: string
          description: 查询铸币的回显（本机时为SOL伪造币）
          example: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
        isNative:
          type: boolean
          description: 结果是否为本机SOL
          example: false
        balance:
          type: string
          description: 人类可读的金额，以十进制**字符串**表示（不是数字，因此大余额不会丢失精度）。尾随零会被截去。
          example: '284961463.392936'
        balanceRaw:
          type: string
          description: 以最小单位（SOL的lamports）表示的精确金额，字符串格式
          example: '284961463392936'
        decimals:
          type: integer
          description: 代币小数位数（SOL为9）
          example: 6
        requested:
          type: object
          description: 查询的回显。当使用`datetime`时，`time`也被填充为解析的纪元秒数，以便UTC解释可见。
          properties:
            time:
              type: integer
              nullable: true
              description: 以纪元秒为单位的请求时间（也在使用`datetime`时设置）
              example: 1736536800
            slot:
              type: integer
              nullable: true
              description: 请求的插槽，当使用`slot`时
              example: null
            datetime:
              type: string
              nullable: true
              description: 原始日期时间字符串，当使用`datetime`时
              example: null
          required:
            - time
            - slot
            - datetime
        asOf:
          type: object
          nullable: true
          description: 读取余额的交易。**当钱包在请求点或之前没有与交易匹配时为`null`** — 意味着余额为`0`（钱包之前未持有代币），不是错误。
          properties:
            slot:
              type: integer
              description: 交易的插槽
              example: 313000000
            blockTime:
              type: integer
              nullable: true
              description: 交易的区块时间，以Unix秒为单位（可能为null）
              example: 1736536794
            signature:
              type: string
              description: 交易签名
              example: 5Cyy7Mh9nVgFq3T8wJp2sKxR4dE6bA1uZoNcLrXmYqUpon
          required:
            - slot
            - signature
      required:
        - wallet
        - mint
        - isNative
        - balance
        - balanceRaw
        - decimals
        - requested
        - asOf
    Error:
      type: object
      properties:
        error:
          type: string
          description: 错误信息
          example: 无效的钱包地址
        code:
          type: integer
          description: HTTP状态代码
          example: 400
        details:
          type: string
          description: 附加错误详情
          example: '''invalid-address'' 不是有效的 Solana 地址'
      required:
        - error
        - code
  responses:
    Unauthorized:
      description: 缺少或无效的API密钥
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: 需要API密钥。通过?api-key=xxx或X-Api-Key头传递
            code: 401
    RateLimited:
      description: 超出速率限制。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: RATE_LIMIT_EXCEEDED
            code: 429
            details: 请求过多。请在 2 秒后重试。
    InternalError:
      description: 临时服务器错误。可以使用指数退避重试。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: INTERNAL_ERROR
            code: 500
            details: 发生意外错误。请重试。
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api-key
      description: 作为查询参数传递的API密钥
    ApiKeyHeader:
      type: apiKey
      in: header
      name: X-Api-Key
      description: 在请求头中传递的API密钥

````