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

# getProgramAccountsV2

> Returns all accounts owned by the provided program Pubkey with enhanced pagination support. This V2 method provides efficient querying with cursor-based pagination, filtering capabilities, and incremental updates for large result sets.

<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 querying program accounts significantly faster.

  **What makes it different:**

  Need to track only new accounts? Use `changedSince` to fetch accounts modified after a specific slot, perfect for incremental updates without re-fetching everything. Want to filter out dust? The `excludeZero` parameter automatically hides empty token accounts, reducing bandwidth and speeding up your queries.
  Use cursor pagination to efficiently retrieve all accounts (up to 10k per request.)
</Tip>


## OpenAPI

````yaml getprogramaccountsv2 post /
openapi: 3.1.0
info:
  title: Solana RPC
  version: 1.0.0
servers:
  - url: https://rpc-mainnet.solanatracker.io
    description: Mainnet RPC endpoint
security: []
paths:
  /:
    post:
      summary: getProgramAccountsV2
      description: >-
        Returns all accounts owned by the provided program Pubkey with enhanced
        pagination support. This V2 method provides efficient querying with
        cursor-based pagination, filtering capabilities, and incremental updates
        for large result sets.
      operationId: getprogramaccountsv2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jsonrpc:
                  allOf:
                    - type: string
                      description: The JSON-RPC protocol version.
                      enum:
                        - '2.0'
                      example: '2.0'
                      default: '2.0'
                id:
                  allOf:
                    - type: string
                      description: A unique identifier for the request.
                      example: '1'
                      default: '1'
                method:
                  allOf:
                    - type: string
                      description: The name of the RPC method to invoke.
                      enum:
                        - getProgramAccountsV2
                      example: getProgramAccountsV2
                      default: getProgramAccountsV2
                params:
                  allOf:
                    - type: array
                      description: Parameters for the enhanced paginated method.
                      default:
                        - TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                        - encoding: base64
                          limit: 1000
                      items:
                        oneOf:
                          - type: string
                            description: >-
                              The Solana program public key (address) to query
                              accounts for, as a base-58 encoded string.
                            example: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                          - type: object
                            description: >-
                              Enhanced configuration options with pagination
                              support for optimizing program account queries.
                            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
                              withContext:
                                type: boolean
                                description: Wrap the result in an RpcResponse JSON object.
                                example: true
                              encoding:
                                type: string
                                description: Encoding format for the returned account data.
                                enum:
                                  - jsonParsed
                                  - base58
                                  - base64
                                  - base64+zstd
                                example: base64
                              dataSlice:
                                type: object
                                description: Request a slice of the account's data.
                                properties:
                                  length:
                                    type: integer
                                    description: Number of bytes to return.
                                    example: 50
                                  offset:
                                    type: integer
                                    description: Byte offset from which to start reading.
                                    example: 0
                              limit:
                                type: integer
                                description: >-
                                  Maximum number of 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 accounts that were modified at or
                                  after this slot number. Useful for incremental
                                  updates.
                                example: 12345678
                              excludeZero:
                                type: boolean
                                description: >-
                                  Exclude all empty accounts (accounts with zero
                                  token balance).
                                example: true
                              filters:
                                type: array
                                description: >-
                                  Powerful filtering system to efficiently query
                                  specific Solana account data patterns.
                                items:
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Filter Solana accounts by their exact
                                        data size in bytes.
                                      properties:
                                        dataSize:
                                          type: integer
                                          description: >-
                                            The exact size of the account data in
                                            bytes for filtering.
                                          example: 165
                                    - type: object
                                      description: >-
                                        Filter Solana accounts by comparing data
                                        at specific memory offsets (most
                                        powerful filter).
                                      properties:
                                        memcmp:
                                          type: object
                                          description: >-
                                            Memory comparison filter for finding
                                            accounts with specific data patterns.
                                          properties:
                                            offset:
                                              type: integer
                                              description: >-
                                                Byte offset within account data to
                                                perform the comparison.
                                              example: 4
                                            bytes:
                                              type: string
                                              description: >-
                                                Base-58 encoded data to compare at the
                                                specified offset position.
                                              example: 3Mc6vR
              required:
                - jsonrpc
                - id
                - method
                - params
            examples:
              base64Example:
                summary: Request with base64 encoding and memcmp filter
                value:
                  jsonrpc: '2.0'
                  id: 1
                  method: getProgramAccountsV2
                  params:
                    - TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                    - encoding: base64
                      filters:
                        - memcmp:
                            offset: 0
                            bytes: 9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump
              jsonParsedExample:
                summary: Request with jsonParsed encoding and memcmp filter
                value:
                  jsonrpc: '2.0'
                  id: 1
                  method: getProgramAccountsV2
                  params:
                    - TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                    - encoding: jsonParsed
                      filters:
                        - memcmp:
                            offset: 0
                            bytes: 9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump
      responses:
        '200':
          description: Successfully retrieved paginated program accounts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        enum:
                          - '2.0'
                        example: '2.0'
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                  result:
                    allOf:
                      - type: object
                        description: Paginated program accounts with navigation metadata.
                        properties:
                          accounts:
                            type: array
                            description: List of program accounts for the current page.
                            items:
                              type: object
                              properties:
                                pubkey:
                                  type: string
                                  description: >-
                                    The account Pubkey as a base-58 encoded
                                    string.
                                  example: CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY
                                account:
                                  type: object
                                  description: Details about the account.
                                  properties:
                                    lamports:
                                      type: integer
                                      description: >-
                                        Number of lamports assigned to this
                                        account.
                                      example: 15298080
                                    owner:
                                      type: string
                                      description: >-
                                        Base-58 encoded Pubkey of the program
                                        this account is assigned to.
                                      example: >-
                                        TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                                    data:
                                      type: array
                                      description: >-
                                        Account data as encoded binary or JSON
                                        format.
                                      items:
                                        type: string
                                      example:
                                        - 2R9jLfiAQ9bgdcw6h8s44439
                                        - base64
                                    executable:
                                      type: boolean
                                      description: >-
                                        Indicates if the account contains a
                                        program.
                                      example: false
                                    rentEpoch:
                                      type: integer
                                      description: >-
                                        The epoch at which this account will
                                        next owe rent.
                                      example: 28
                                    space:
                                      type: integer
                                      description: The data size of the account.
                                      example: 165
                          cursor:
                            type: string
                            description: >-
                              Pagination cursor for the next page. Null only
                              when no accounts are returned (end of pagination).
                              Note that fewer accounts than the limit may be
                              returned due to filtering, but this does not
                              indicate end of pagination.
                            example: 8WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM
                            nullable: true
                          totalCount:
                            type: integer
                            description: Total number of accounts matching the query.
                            example: 25000
                            nullable: true
              examples:
                base64Example:
                  summary: Response with base64 encoded data
                  value:
                    jsonrpc: '2.0'
                    id: 1
                    result:
                      context:
                        apiVersion: 3.0.0
                        slot: 372914918
                      value:
                        accounts:
                          - account:
                              data:
                                - >-
                                  eXi3FEU80+h66x/Am/Bn+WzS1NabVxOVqpvxhq/52j8l9waSAkTeKVuHU8I65mfMdK85hgfUpKL9h/QyGL3xowAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                                - base64
                              executable: false
                              lamports: 2039280
                              owner: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                              rentEpoch: 18446744073709552000
                              space: 165
                            pubkey: 11966FYd2Gtp2wBAXdGzGcJuQaHMLoqVoJDsAvXreb2
                        hasMore: true
                        nextCursor: 11966FYd2Gtp2wBAXdGzGcJuQaHMLoqVoJDsAvXreb2
                        totalCount: 25655
                jsonParsedExample:
                  summary: Response with jsonParsed data
                  value:
                    jsonrpc: '2.0'
                    id: 1
                    result:
                      context:
                        apiVersion: 3.0.0
                        slot: 372915045
                      value:
                        accounts:
                          - account:
                              data:
                                parsed:
                                  info:
                                    isNative: false
                                    mint: >-
                                      9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump
                                    owner: >-
                                      3ZCZDvyFQswEezauPTHeR82yq5ghipa65s8rUVTPSM8v
                                    state: initialized
                                    tokenAmount:
                                      amount: '0'
                                      decimals: 6
                                      uiAmount: 0
                                      uiAmountString: '0'
                                  type: account
                                program: spl-token
                                space: 165
                              executable: false
                              lamports: 2039280
                              owner: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                              rentEpoch: 18446744073709552000
                              space: 165
                            pubkey: 11966FYd2Gtp2wBAXdGzGcJuQaHMLoqVoJDsAvXreb2
                        hasMore: true
                        nextCursor: 11966FYd2Gtp2wBAXdGzGcJuQaHMLoqVoJDsAvXreb2
                        totalCount: 25655
        '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.
                        enum:
                          - '2.0'
                        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
                        description: The JSON-RPC protocol version.
                        enum:
                          - '2.0'
                        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
                        description: The JSON-RPC protocol version.
                        enum:
                          - '2.0'
                        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
                        description: The JSON-RPC protocol version.
                        enum:
                          - '2.0'
                        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
                        description: The JSON-RPC protocol version.
                        enum:
                          - '2.0'
                        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
                        description: The JSON-RPC protocol version.
                        enum:
                          - '2.0'
                        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

````