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

# getTokenAccounts DAS 方法

> 按所有者、mint 或两者列出 SPL Token 和 Token-2022 账户，按地址排序，支持游标或页码分页。查看 getTokenAccounts 的参数和代码示例。

涵盖 SPL Token 和 Token-2022 账户，按代币账户地址排序。也可使用 `get_token_accounts` 调用。

* 传入 `owner`、`mint` 或两者。`ownerAddress` 和 `mintAddress` 可作为别名使用。
* 除非 `options.showZeroBalance` 为 `true`，否则不显示空代币账户。
* `amount` 是以基础单位表示的原始余额。
* `limit` 默认为 1000，且不能超过 1000。
* 未传入 `page`、`before` 或 `after` 时，响应中的 `cursor` 是最后一个账户的地址。将其作为 `cursor` 传回以获取下一页；`token_accounts` 为空时停止。
* 匹配超过 200,000 个代币账户的查询会返回错误，因此对持有者众多的代币，仅用 `mint` 查询无法生效。请加上 `owner`，或使用 [getTokenLargestAccounts](https://docs.solanatracker.io/cn/solana-rpc/http/gettokenlargestaccounts.md)。
* 消耗 1 积分，并计入套餐的 DAS RPS 限制。

请求配置和错误处理见 [RPC 快速入门](https://docs.solanatracker.io/cn/solana-rpc/quickstart.md)。计费见[积分与限制](https://docs.solanatracker.io/cn/solana-rpc/credits-and-rate-limits.md)。

全部 DAS 方法见 [DAS API 概览](https://docs.solanatracker.io/cn/solana-rpc/das-api.md)。


## OpenAPI

````yaml gettokenaccounts post /
openapi: 3.1.0
info:
  title: Solana RPC
  version: 1.0.0
  description: Solana RPC HTTP method reference.
servers:
  - url: https://rpc-mainnet.solanatracker.io
    description: Mainnet RPC endpoint
security: []
paths:
  /:
    post:
      summary: getTokenAccounts
      description: >-
        List SPL Token and Token-2022 accounts by owner, by mint, or by both,
        sorted by token account address. Empty accounts are hidden unless
        `showZeroBalance` is set.
      operationId: gettokenaccounts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jsonrpc:
                  allOf:
                    - type: string
                      description: The JSON-RPC protocol version.
                      example: '2.0'
                      enum:
                        - '2.0'
                id:
                  allOf:
                    - type: string
                      description: A unique identifier for the request.
                      example: '1'
                method:
                  allOf:
                    - type: string
                      description: The name of the RPC method to invoke.
                      example: getTokenAccounts
                      enum:
                        - getTokenAccounts
                params:
                  allOf:
                    - type: object
                      description: >-
                        Owner and/or mint, and pagination. Send at least one of
                        `owner` or `mint`. Unknown keys are rejected.
                      properties:
                        owner:
                          type: string
                          description: Owner wallet. Also accepted as `ownerAddress`.
                          example: 86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY
                        mint:
                          type: string
                          description: Token mint. Also accepted as `mintAddress`.
                          example: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                        limit:
                          type: integer
                          description: Maximum items per page. Default 1000, maximum 1000.
                          example: 100
                          default: 1000
                          minimum: 1
                          maximum: 1000
                        page:
                          type: integer
                          description: >-
                            1-based page number. Cannot be combined with
                            `before`, `after` or `cursor`.
                          example: 1
                          minimum: 1
                        cursor:
                          type: string
                          description: >-
                            Token account address from the previous response's
                            `cursor`. Returns accounts after it.
                        before:
                          type: string
                          description: >-
                            Return token accounts with an address lower than
                            this one (exclusive).
                        after:
                          type: string
                          description: >-
                            Return token accounts with an address higher than
                            this one (exclusive).
                        options:
                          type: object
                          description: Display options. Also accepted as `displayOptions`.
                          properties:
                            showZeroBalance:
                              type: boolean
                              description: Include token accounts with a zero balance.
                              example: false
                              default: false
              required:
                - jsonrpc
                - id
                - method
                - params
            examples:
              ownerExample:
                summary: All token accounts of a wallet
                value:
                  jsonrpc: '2.0'
                  id: 1
                  method: getTokenAccounts
                  params:
                    owner: 86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY
                    limit: 100
              ownerMintExample:
                summary: A wallet's accounts for one mint
                value:
                  jsonrpc: '2.0'
                  id: 1
                  method: getTokenAccounts
                  params:
                    owner: 86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY
                    mint: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                    options:
                      showZeroBalance: true
      responses:
        '200':
          description: Successfully retrieved token accounts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        example: '2.0'
                        enum:
                          - '2.0'
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                  result:
                    allOf:
                      - type: object
                        description: A page of token accounts.
                        properties:
                          total:
                            type: integer
                            description: Number of token accounts on this page.
                            example: 2
                          limit:
                            type: integer
                            description: Page size used.
                            example: 100
                          page:
                            type: integer
                            description: Echoed when paging by `page`.
                          cursor:
                            type:
                              - string
                              - 'null'
                            description: >-
                              Address of the last token account when paging by
                              cursor (no `page`, `before` or `after`); otherwise
                              `null`.
                          token_accounts:
                            type: array
                            description: Token accounts.
                            items:
                              type: object
                              description: A token account.
                              properties:
                                address:
                                  type: string
                                  description: Token account address.
                                mint:
                                  type: string
                                  description: Mint.
                                amount:
                                  type: integer
                                  description: Raw balance in base units.
                                owner:
                                  type: string
                                  description: Owner wallet.
                                frozen:
                                  type: boolean
                                  description: Whether the account is frozen.
                                delegate:
                                  type:
                                    - string
                                    - 'null'
                                  description: Delegate address, or `null`.
                                delegated_amount:
                                  type: integer
                                  description: Amount the delegate may transfer.
                                close_authority:
                                  type: 'null'
                                  description: Always `null`.
                                extensions:
                                  type: 'null'
                                  description: Always `null`.
                          errors:
                            type: array
                            description: Always empty.
                            example: []
                          last_indexed_slot:
                            type: integer
                            description: The latest slot included in the results.
                            example: 386120417
              examples:
                example:
                  summary: Successful response
                  value:
                    jsonrpc: '2.0'
                    id: 1
                    result:
                      total: 2
                      limit: 100
                      token_accounts:
                        - address: AUH6c4QLMr2qQr9N5Kkpz5astDM9gBNroXCSxQiFTGQv
                          mint: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                          amount: 2500000
                          owner: 86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY
                          frozen: false
                          delegate: null
                          delegated_amount: 0
                          close_authority: null
                          extensions: null
                        - address: DYougPS3ao5Ticdy5bFcKKcXgSjHVJ2yuwaMgxHpPoQr
                          mint: So11111111111111111111111111111111111111112
                          amount: 120000000
                          owner: 86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY
                          frozen: false
                          delegate: null
                          delegated_amount: 0
                          close_authority: null
                          extensions: null
                      cursor: DYougPS3ao5Ticdy5bFcKKcXgSjHVJ2yuwaMgxHpPoQr
                      errors: []
                      last_indexed_slot: 386120417
        '400':
          description: Bad Request - Invalid request parameters or malformed request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        example: '2.0'
                        enum:
                          - '2.0'
                  error:
                    allOf:
                      - type: object
                        properties:
                          code:
                            type: integer
                            description: The error code.
                            example: -32602
                          message:
                            type: string
                            description: The error message.
                          data:
                            type: object
                            description: Additional data about the error.
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                refIdentifier: '#/components/schemas/ErrorResponse'
              examples:
                example:
                  value:
                    jsonrpc: '2.0'
                    error:
                      code: -32602
                      message: Invalid params
                    id: 1
        '401':
          description: Unauthorized - Invalid or missing API key.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        example: '2.0'
                        enum:
                          - '2.0'
                  error:
                    allOf:
                      - type: object
                        properties:
                          code:
                            type: integer
                            description: The error code.
                            example: -32602
                          message:
                            type: string
                            description: The error message.
                          data:
                            type: object
                            description: Additional data about the error.
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                refIdentifier: '#/components/schemas/ErrorResponse'
              examples:
                example:
                  value:
                    jsonrpc: '2.0'
                    error:
                      code: -32001
                      message: Unauthorized
                    id: 1
        '429':
          description: Too Many Requests - Rate limit exceeded.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        example: '2.0'
                        enum:
                          - '2.0'
                  error:
                    allOf:
                      - type: object
                        properties:
                          code:
                            type: integer
                            description: The error code.
                            example: -32602
                          message:
                            type: string
                            description: The error message.
                          data:
                            type: object
                            description: Additional data about the error.
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                refIdentifier: '#/components/schemas/ErrorResponse'
              examples:
                example:
                  value:
                    jsonrpc: '2.0'
                    error:
                      code: -32005
                      message: Too many requests
                    id: 1
        '500':
          description: Internal Server Error - An error occurred on the server.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        example: '2.0'
                        enum:
                          - '2.0'
                  error:
                    allOf:
                      - type: object
                        properties:
                          code:
                            type: integer
                            description: The error code.
                            example: -32602
                          message:
                            type: string
                            description: The error message.
                          data:
                            type: object
                            description: Additional data about the error.
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                refIdentifier: '#/components/schemas/ErrorResponse'
              examples:
                example:
                  value:
                    jsonrpc: '2.0'
                    error:
                      code: -32603
                      message: Internal error
                    id: 1
        '503':
          description: Service Unavailable - The service is temporarily unavailable.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        example: '2.0'
                        enum:
                          - '2.0'
                  error:
                    allOf:
                      - type: object
                        properties:
                          code:
                            type: integer
                            description: The error code.
                            example: -32602
                          message:
                            type: string
                            description: The error message.
                          data:
                            type: object
                            description: Additional data about the error.
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                refIdentifier: '#/components/schemas/ErrorResponse'
              examples:
                example:
                  value:
                    jsonrpc: '2.0'
                    error:
                      code: -32002
                      message: Service unavailable
                    id: 1
        '504':
          description: Gateway Timeout - The request timed out.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        example: '2.0'
                        enum:
                          - '2.0'
                  error:
                    allOf:
                      - type: object
                        properties:
                          code:
                            type: integer
                            description: The error code.
                            example: -32602
                          message:
                            type: string
                            description: The error message.
                          data:
                            type: object
                            description: Additional data about the error.
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                refIdentifier: '#/components/schemas/ErrorResponse'
              examples:
                example:
                  value:
                    jsonrpc: '2.0'
                    error:
                      code: -32003
                      message: Gateway timeout
                    id: 1
      security:
        - ApiKeyQuery: []
components:
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key

````

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