# getProgramAccountsV2

> Page through a program's accounts in fixed-size chunks using a cursor, instead of one unbounded response.

Source: https://docs.constant-k.com/rpc/http/getprogramaccountsv2/

`getProgramAccountsV2` takes the same filters as `getProgramAccounts` and adds `limit`, `paginationKey` and `changedSinceSlot`, paging through the account set instead of returning it all at once. Pages hold up to 10,000 accounts, 1,000 by default.

This constant-k method is modeled on Helius' `getProgramAccountsV2` and is available on Blade Runner and Nexus. The first call omits `paginationKey`; each subsequent call passes back the previous page's `paginationKey`, until the response returns `null`.

- Transport: HTTP, JSON-RPC 2.0 `POST` to `https://rpc-newyork.constant-k.com/?api-key=YOUR_API_KEY` (New York) or `https://rpc-frankfurt.constant-k.com/?api-key=YOUR_API_KEY` (Frankfurt) or `https://rpc-amsterdam.constant-k.com/?api-key=YOUR_API_KEY` (Amsterdam). The key also works as an `x-api-key` header.
- Category: Accounts
- Availability: Blade Runner and above
- Rate limits: Free not available · Operator not available · Blade Runner 25/s · Nexus 75/s

## Parameters

`params` is a positional JSON array, in this order:

- `programId` (string, required): Base58-encoded public key of the program whose accounts to list.
- `config` (object, optional): Filtering, encoding, and pagination settings.
  - `encoding` (string, optional, one of `base58`, `base64`, `base64+zstd`, `jsonParsed`, default `"base58"`): Format for each account's `data`. `jsonParsed` falls back to `base64` when no program-specific parser is available.
  - `commitment` (string, optional, one of `processed`, `confirmed`, `finalized`, default `"finalized"`): How settled the account/transaction state must be before the node acts on it. `processed` is fastest and can roll back; `finalized` is slowest and never rolls back.
  - `minContextSlot` (integer, optional, min 0): Minimum slot the node must have reached before evaluating the request.
  - `withContext` (boolean, optional, default `false`): Wrap the result as `{context: {slot, apiVersion}, value: {accounts, paginationKey}}` instead of returning `{accounts, paginationKey}` directly.
  - `dataSlice` (object, optional): Return only a byte range of each account's `data` instead of the whole thing. Not compatible with `jsonParsed`.
    - `offset` (integer, required, min 0): Byte offset.
    - `length` (integer, required, min 0): Number of bytes.
  - `filters` (object[], optional): Server-side filters; an account must match all of them to be included. Same shape as `getProgramAccounts`.
  - `limit` (integer, optional, default `1000`, min 1, max 10000): Maximum accounts to return in this page, from 1 to 10,000. Optional: leave it out and the page holds up to 1,000 accounts.
  - `paginationKey` (string | null, optional): Cursor for the next page: the base58 account public key returned as `paginationKey` by the previous call. Omit it on the first call; stop paginating once the response's `paginationKey` is `null`.
  - `changedSinceSlot` (integer, optional, min 0): Return only accounts modified at or after this slot. Use it to poll for changes instead of re-reading the whole account set.

## Result

- `result` (object, optional): A page of matching accounts plus the cursor for the next page (or `null` on the last page).
  - `option 1` (object, optional): Default shape, used when `withContext` is false or omitted.
    - `accounts` (object[], required): The page of matching accounts.
      - `pubkey` (string, optional): Base58 public key of the account.
      - `account` (object, optional): The account's on-chain state.
        - `lamports` (integer, optional): Account balance, in lamports.
        - `owner` (string, optional): Base58 address of the program (or, for a token account, the wallet) that owns this account.
        - `data` (any, optional): Account data.
        - `executable` (boolean, optional): Whether this account is a program.
        - `rentEpoch` (integer, optional): Legacy rent-exemption epoch; not meaningful for accounts created after rent-exempt minimums became mandatory.
        - `space` (integer, optional): Size of the account's data, in bytes.
    - `paginationKey` (string | null, required): Base58 public key of the last account in this page. Passing it back as `paginationKey` fetches the next page; it is `null` on the last page, the only end-of-results signal.
  - `option 2` (object, optional): Shape used when `withContext` is true.
    - `context` (object, required): Response context, including the slot the data was read at.
      - `slot` (integer, optional): Slot number this applies to.
      - `apiVersion` (string, optional): RPC node software version that produced this response.
    - `value` (object, required): The requested data; see the fields below.
      - `accounts` (array, optional): The page of matching accounts.
      - `paginationKey` (string | null, optional): Cursor for the next page; null once there are no more pages.

## Example: First page

Request:

```bash
curl "https://rpc-newyork.constant-k.com/?api-key=YOUR_API_KEY" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getProgramAccountsV2",
    "params": [
      "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
      { "encoding": "base64", "commitment": "confirmed", "limit": 2 }
    ]
  }'
```

Response:

```json
{
  "jsonrpc": "2.0",
  "result": {
    "accounts": [
      {
        "pubkey": "CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY",
        "account": {
          "lamports": 2039280,
          "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
          "data": [
            "ZGF0YSBwbGFjZWhvbGRlcg==",
            "base64"
          ],
          "executable": false,
          "rentEpoch": 18446744073709552000,
          "space": 165
        }
      },
      {
        "pubkey": "9BvVqz9NLNGWvJsyt3G4NyfMfWDLGkTuQP7UjJv6xR7q",
        "account": {
          "lamports": 2039280,
          "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
          "data": [
            "ZGF0YSBwbGFjZWhvbGRlcg==",
            "base64"
          ],
          "executable": false,
          "rentEpoch": 18446744073709552000,
          "space": 165
        }
      }
    ],
    "paginationKey": "26EnQkdnk6fCTY85oSBAxQAQV2Mboku4rtGYY8nPzHvL"
  },
  "id": 1
}
```

_Long arrays in this example were trimmed._

## Example: Final page

Request:

```bash
curl "https://rpc-newyork.constant-k.com/?api-key=YOUR_API_KEY" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getProgramAccountsV2",
    "params": [
      "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
      {
        "encoding": "base64",
        "commitment": "confirmed",
        "limit": 2,
        "paginationKey": "3M1EAxRZKAtXKrpuHRxKa4vSpEBqEuP8Z1uy3rC9DZ5A"
      }
    ]
  }'
```

Response:

```json
{
  "jsonrpc": "2.0",
  "result": {
    "accounts": [
      {
        "pubkey": "3M1EAxRZKAtXKrpuHRxKa4vSpEBqEuP8Z1uy3rC9DZ5A",
        "account": {
          "lamports": 2039280,
          "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
          "data": [
            "ZGF0YSBwbGFjZWhvbGRlcg==",
            "base64"
          ],
          "executable": false,
          "rentEpoch": 18446744073709552000,
          "space": 165
        }
      }
    ],
    "paginationKey": null
  },
  "id": 1
}
```

## Notes

- Available on Blade Runner at 25 requests per second and on Nexus at 75 per second. Free and Operator keys get HTTP `403` with `getProgramAccountsV2 requires higher tier`.
- A page can come back with fewer accounts than `limit`, or zero, without that meaning the end; only a `null` `paginationKey` signals the end, which the last page always carries.
- Program scans follow `getProgramAccounts` rules: at least one selective filter (`memcmp` or `dataSize`), token-program scans owner-scoped via `dataSize: 165` plus a `memcmp` of the 32-byte owner at offset 32.
- Twelve hot programs are answered from a purpose-built in-memory index rather than an account scan: a fraction of a second, no scan-results cap, and no filter required. Every other program is scanned on disk, where the filter requirement and scan limits above apply.

| Program | Program ID |
| --- | --- |
| Address Lookup Table | `AddressLookupTab1e1111111111111111111111111` |
| Raydium AMM V4 | `675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8` |
| Raydium CPMM | `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C` |
| Raydium CLMM | `CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK` |
| Orca Whirlpool | `whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc` |
| Meteora DLMM | `LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo` |
| Meteora DAMM V2 | `cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG` |
| Meteora DBC | `dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN` |
| Pump.fun | `6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P` |
| PumpSwap | `pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA` |
| Serum V3 | `9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin` |
| Drift V2 | `dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH` |

