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

# getProgramAccounts

> Runs the Solana RPC `getProgramAccounts` method.

<Tip>
  **⚡ 由 Solana Ridge DB 提供支持**

  通过 **Ridge DB**(我们专为 Solana 上的高性能账户检索而定制构建的客户端)获取更快的 Solana 账户数据。与标准 RPC 方法不同,Ridge DB 使用专门的索引,使查询程序账户的速度显著加快。

  **它的与众不同之处:**

  只需追踪新账户?使用 `changedSince` 获取在某个 slot 之后修改的账户,这样您就不必重新加载所有内容。使用游标分页可以高效检索所有匹配的账户,每次请求最多 10k 条。
</Tip>

<Warning>
  **高负载注意事项**

  此端点会将所有账户直接流式返回给您的客户端。虽然在大多数查询场景下表现良好,但在高负载或查询拥有数百万账户的程序(例如流动性池或协议拥有的账户)时,可能会返回错误。

  **需要更高的可靠性?** 请改用 **[getProgramAccountsV2](/cn/solana-rpc/http/getprogramaccountsv2)**。V2 方法包含分页支持,对于大型程序和高流量场景更加高效和可靠。
</Warning>


## OpenAPI

````yaml getprogramaccounts 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: getProgramAccounts
      description: Runs the Solana RPC `getProgramAccounts` method.
      operationId: getprogramaccounts
      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:
                        - getProgramAccounts
                      example: getProgramAccounts
                      default: getProgramAccounts
                params:
                  allOf:
                    - type: array
                      description: Parameters for the method.
                      default:
                        - 4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T
                      items:
                        oneOf:
                          - type: string
                            description: >-
                              The Solana program public key (address) to query
                              accounts for, as a base-58 encoded string.
                            example: 4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T
                          - type: object
                            description: >-
                              Advanced configuration options 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: jsonParsed
                              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
                              changedSinceSlot:
                                type: integer
                                description: >-
                                  Only return accounts that were modified at or
                                  after this slot number. Useful for incremental
                                  updates.
                                example: 464175999
                              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: 17
                                    - 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:
              example:
                value:
                  jsonrpc: '2.0'
                  id: db16f277-1a22-41ff-9f85-f37e2cd77900
                  method: getProgramAccounts
                  params:
                    - 4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T
      responses:
        '200':
          description: Successfully retrieved 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:
                      - oneOf:
                          - type: array
                            description: List of program accounts.
                            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: >-
                                        4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T
                                    data:
                                      type: array
                                      description: >-
                                        Account data as encoded binary or JSON
                                        format.
                                      items:
                                        type: string
                                      example:
                                        - 2R9jLfiAQ9bgdcw6h8s44439
                                        - base58
                                    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: 42
              examples:
                example:
                  value:
                    jsonrpc: '2.0'
                    id: db16f277-1a22-41ff-9f85-f37e2cd77900
                    result:
                      - pubkey: CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY
                        account:
                          lamports: 15298080
                          owner: 4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T
                          data:
                            - 2R9jLfiAQ9bgdcw6h8s44439
                            - base58
                          executable: false
                          rentEpoch: 28
                          space: 42
        '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
                      data: {}
                    id: db16f277-1a22-41ff-9f85-f37e2cd77900
        '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
                      data: {}
                    id: db16f277-1a22-41ff-9f85-f37e2cd77900
        '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
                      data: {}
                    id: db16f277-1a22-41ff-9f85-f37e2cd77900
        '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
                      data: {}
                    id: db16f277-1a22-41ff-9f85-f37e2cd77900
        '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
                      data: {}
                    id: db16f277-1a22-41ff-9f85-f37e2cd77900
        '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
                      data: {}
                    id: db16f277-1a22-41ff-9f85-f37e2cd77900
      security:
        - ApiKeyQuery: []
components:
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key

````