> ## 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.

# getTokenAccountsByOwnerV2

> Returns all SPL Token accounts owned by the provided wallet address with enhanced pagination support. This V2 method provides efficient querying with cursor-based pagination, filtering by mint or program ID, and incremental updates for portfolio tracking.

<Tip>
  **⚡ Powered by Solana Ridge DB**

  Get faster Solana account data with **Ridge DB**, our custom-built client designed specifically for high-performance account retrieval on Solana. Unlike standard RPC methods, Ridge DB uses specialized indexes that make wallet token-account lookups significantly faster.

  **What makes it different:**

  Need to track token holdings for one wallet? Use `changedSince` to fetch only token accounts modified after a specific slot, so you do not have to reload the full wallet each time. Want to filter out dust? The `excludeZero` parameter hides empty token accounts, reducing bandwidth and speeding up your queries.
  Use cursor pagination to retrieve large token-account lists efficiently, up to 10k accounts per request.
</Tip>


## OpenAPI

````yaml gettokenaccountsbyownerv2 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: Run `getTokenAccountsByOwnerV2`
      description: >-
        Returns all SPL Token accounts owned by the provided wallet address with
        enhanced pagination support. This V2 method provides efficient querying
        with cursor-based pagination, filtering by mint or program ID, and
        incremental updates for portfolio tracking.
      operationId: gettokenaccountsbyownerv2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jsonrpc:
                  allOf:
                    - type: string
                      enum:
                        - '2.0'
                      description: The JSON-RPC protocol version.
                      example: '2.0'
                id:
                  allOf:
                    - type: string
                      description: A unique identifier for the request.
                      example: '1'
                method:
                  allOf:
                    - type: string
                      enum:
                        - getTokenAccountsByOwnerV2
                      description: The name of the RPC method to invoke.
                      example: getTokenAccountsByOwnerV2
                      default: getTokenAccountsByOwnerV2
                params:
                  allOf:
                    - type: array
                      description: >-
                        Parameters for querying paginated token accounts owned
                        by a specific public key.
                      default:
                        - A1TMhSGzQxMr1TboBKtgixKz1sS6REASMxPo1qsyTSJd
                        - programId: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                        - encoding: jsonParsed
                          limit: 1000
                      items:
                        oneOf:
                          - type: string
                            description: >-
                              Solana wallet address (pubkey) of the account
                              owner to query token holdings for, as a base-58
                              encoded string.
                            example: A1TMhSGzQxMr1TboBKtgixKz1sS6REASMxPo1qsyTSJd
                          - type: object
                            description: >-
                              Filter configuration to narrow down token accounts
                              by mint address or program ID.
                            properties:
                              mint:
                                type: string
                                description: >-
                                  Specific Solana token mint address to retrieve
                                  only accounts for a particular token or NFT.
                                example: 2cHr7QS3xfuSV8wdxo3ztuF4xbiarF6Nrgx3qpx3HzXR
                              programId:
                                type: string
                                description: >-
                                  Specific Solana token program ID (typically
                                  SPL Token program) that created the token
                                  accounts.
                                example: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                          - type: object
                            description: >-
                              Enhanced configuration object with pagination
                              support and optional fields.
                            properties:
                              commitment:
                                type: string
                                description: The commitment level for the request.
                                enum:
                                  - confirmed
                                  - finalized
                                  - processed
                                example: finalized
                              minContextSlot:
                                type: integer
                                description: >-
                                  The minimum slot that the request can be
                                  evaluated at.
                                example: 1000
                              dataSlice:
                                type: object
                                description: Request a slice of the account's data.
                                properties:
                                  length:
                                    type: integer
                                    description: Number of bytes to return.
                                    example: 10
                                  offset:
                                    type: integer
                                    description: Byte offset from which to start reading.
                                    example: 0
                              encoding:
                                type: string
                                description: Encoding format for Account data.
                                enum:
                                  - base58
                                  - base64
                                  - base64+zstd
                                  - jsonParsed
                                example: jsonParsed
                              limit:
                                type: integer
                                description: >-
                                  Maximum number of token accounts to return per
                                  request (1-10,000).
                                minimum: 1
                                maximum: 10000
                                example: 1000
                              cursor:
                                type: string
                                description: >-
                                  Base-58 encoded pagination cursor for fetching
                                  subsequent pages. Use the cursor from previous
                                  response.
                                example: 9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM
                              changedSince:
                                type: integer
                                description: >-
                                  Only return token accounts that were modified
                                  at or after this slot number. Useful for
                                  incremental portfolio updates.
                                example: 12345678
                              excludeZero:
                                type: boolean
                                description: >-
                                  Exclude all empty accounts (accounts with zero
                                  token balance).
                                example: true
              required:
                - jsonrpc
                - id
                - method
                - params
            examples:
              jsonParsedExample:
                summary: Request with jsonParsed encoding and filters
                value:
                  jsonrpc: '2.0'
                  id: 1
                  method: getTokenAccountsByOwnerV2
                  params:
                    - 5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1
                    - programId: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                    - encoding: jsonParsed
                      limit: 1000
                      changedSince: 372909702
                      excludeZero: true
              base64Example:
                summary: Request with base64 encoding
                value:
                  jsonrpc: '2.0'
                  id: 1
                  method: getTokenAccountsByOwnerV2
                  params:
                    - 5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1
                    - programId: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                    - encoding: base64
                      limit: 1000
      responses:
        '200':
          description: Successfully retrieved paginated token accounts by owner.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        enum:
                          - '2.0'
                        description: The JSON-RPC protocol version.
                        example: '2.0'
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                  result:
                    allOf:
                      - type: object
                        description: Paginated token accounts with navigation metadata.
                        properties:
                          context:
                            type: object
                            description: Context of the response.
                            properties:
                              apiVersion:
                                type: string
                                description: API version.
                                example: 2.0.15
                              slot:
                                type: integer
                                description: Slot in which the data was fetched.
                                example: 341197933
                          value:
                            type: array
                            description: List of token accounts for the current page.
                            items:
                              type: object
                              properties:
                                pubkey:
                                  type: string
                                  description: Account Pubkey as a base-58 encoded string.
                                  example: BGocb4GEpbTFm8UFV2VsDSaBXHELPfAXrvd4vtt8QWrA
                                account:
                                  type: object
                                  description: Token account details.
                                  properties:
                                    lamports:
                                      type: integer
                                      description: >-
                                        Number of lamports assigned to the
                                        account.
                                      example: 2039280
                                    owner:
                                      type: string
                                      description: >-
                                        Pubkey of the program this account has
                                        been assigned to.
                                      example: >-
                                        TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                                    data:
                                      type: object
                                      description: >-
                                        Token state data associated with the
                                        account.
                                      properties:
                                        program:
                                          type: string
                                          description: Program name.
                                          example: spl-token
                                        parsed:
                                          type: object
                                          description: Parsed token data.
                                          properties:
                                            info:
                                              type: object
                                              description: Token account information.
                                              properties:
                                                isNative:
                                                  type: boolean
                                                  description: >-
                                                    Indicates if the account holds native
                                                    SOL.
                                                  example: false
                                                mint:
                                                  type: string
                                                  description: Pubkey of the token mint.
                                                  example: >-
                                                    2cHr7QS3xfuSV8wdxo3ztuF4xbiarF6Nrgx3qpx3HzXR
                                                owner:
                                                  type: string
                                                  description: Pubkey of the account owner.
                                                  example: >-
                                                    A1TMhSGzQxMr1TboBKtgixKz1sS6REASMxPo1qsyTSJd
                                                state:
                                                  type: string
                                                  description: Token account state.
                                                  example: initialized
                                                tokenAmount:
                                                  type: object
                                                  description: Token amount details.
                                                  properties:
                                                    amount:
                                                      type: string
                                                      description: Raw balance without decimals.
                                                      example: '420000000000000'
                                                    decimals:
                                                      type: integer
                                                      description: Number of decimals.
                                                      example: 6
                                                    uiAmount:
                                                      type: number
                                                      description: Balance in user-friendly format.
                                                      example: 420000000
                                                    uiAmountString:
                                                      type: string
                                                      description: Balance as a string.
                                                      example: '420000000'
                                        space:
                                          type: integer
                                          description: Space allocated for the account.
                                          example: 165
                                    executable:
                                      type: boolean
                                      description: >-
                                        Indicates if the account contains a
                                        program.
                                      example: false
                                    rentEpoch:
                                      type: integer
                                      description: >-
                                        Epoch at which the account will next owe
                                        rent.
                                      example: 18446744073709552000
                                    space:
                                      type: integer
                                      description: Data size of the account.
                                      example: 165
                          cursor:
                            type: string
                            description: >-
                              Cursor for the next page. Empty if no more pages
                              are available.
                            example: 8WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM
                            nullable: true
                          totalCount:
                            type: integer
                            description: Total number of accounts matching the query.
                            example: 25000
                            nullable: true
              examples:
                jsonParsedExample:
                  summary: Response with jsonParsed data
                  value:
                    jsonrpc: '2.0'
                    id: 1
                    result:
                      context:
                        apiVersion: 3.0.0
                        slot: 372910193
                      value:
                        accounts:
                          - account:
                              data:
                                parsed:
                                  info:
                                    isNative: false
                                    mint: >-
                                      FGf1Us3kqu9AXu2x1yWKfiKE8uSx42ACvRiUrbuAodzq
                                    owner: >-
                                      5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1
                                    state: initialized
                                    tokenAmount:
                                      amount: '4055486331542675841'
                                      decimals: 9
                                      uiAmount: 4055486331.542676
                                      uiAmountString: '4055486331.542675841'
                                  type: account
                                program: spl-token
                                space: 165
                              executable: false
                              lamports: 2039280
                              owner: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                              rentEpoch: 18446744073709552000
                              space: 165
                            pubkey: AYAmCRPotwZprbNpPQ1hVGSEpbgWUgWHUbjnjt4bfLo1
                        hasMore: true
                        nextCursor: p2b9JXwduXpJn7Vz1DXuBLS4iZDxHNQ3pcmfR6f5rwi
                        totalCount: 25655
                base64Example:
                  summary: Response with base64 encoded data
                  value:
                    jsonrpc: '2.0'
                    id: 1
                    result:
                      context:
                        apiVersion: 3.0.0
                        slot: 372910193
                      value:
                        accounts:
                          - account:
                              data:
                                - >-
                                  4TsOSLfyUb7R9Q7KaTsBN+nurQS+26fdxiaRdxUhbCNBV7BYDzHF/ORKYlgtvPnXjudZQ6CEo5OzUDaNIomTCPifZc1qETiNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                                - base64
                              executable: false
                              lamports: 2039280
                              owner: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                              rentEpoch: 18446744073709552000
                              space: 165
                            pubkey: BCbPgEwL6QLKpzLj54tcaBtHhhU5bKKf1rDBhkydCQBX
                        hasMore: true
                        nextCursor: p2b9JXwduXpJn7Vz1DXuBLS4iZDxHNQ3pcmfR6f5rwi
                        totalCount: 25655
        '400':
          description: Bad Request - Invalid request parameters or malformed request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        enum:
                          - '2.0'
                        description: The JSON-RPC protocol version.
                        example: '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
                        enum:
                          - '2.0'
                        description: The JSON-RPC protocol version.
                        example: '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
                        enum:
                          - '2.0'
                        description: The JSON-RPC protocol version.
                        example: '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
                        enum:
                          - '2.0'
                        description: The JSON-RPC protocol version.
                        example: '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
                        enum:
                          - '2.0'
                        description: The JSON-RPC protocol version.
                        example: '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
                        enum:
                          - '2.0'
                        description: The JSON-RPC protocol version.
                        example: '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

````