# getProgramAccounts

> Returns every account owned by a program, optionally narrowed by size and byte-content filters.

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

`getProgramAccounts` scans every account owned by a program and returns the ones matching the given filters, enumerating a protocol's state without knowing individual addresses ahead of time.

An unfiltered scan walks the program's entire account set — tens of millions of accounts for a program like SPL Token — so constant-k requires at least one filter on every call and meters it separately from the rest of the Accounts category.

- 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): Address of the program whose owned accounts to scan, base-58 encoded.
- `config` (object, required): Configuration. On constant-k this is effectively required, not optional: at least one entry in `filters` must narrow the scan.
  - `commitment` (string, optional, one of `finalized`, `confirmed`, `processed`, default `"finalized"`): Bank state to scan.
  - `encoding` (string, optional, one of `base58`, `base64`, `base64+zstd`, `jsonParsed`, default `"base58"`): How to encode each account's `data`. `base58` fails for accounts over 129 bytes.
  - `dataSlice` (object, optional): Returns only a byte range of each account's `data`. Not valid with `jsonParsed`.
    - `offset` (integer, required)
    - `length` (integer, required)
  - `filters` (object[], required): Accounts must match every filter in this array (logical AND). Required on constant-k — a call with no filters, or with filters too loose to bound the scan, is rejected.
  - `minContextSlot` (integer, optional): Minimum slot the node must have processed before answering.
  - `withContext` (boolean, optional, default `false`): When true, wraps the array result in the usual `{context, value}` envelope instead of returning it bare.

## Result

- `result` (object[] | object, optional): By default, a bare array of matching accounts. With `withContext: true`, the same array wrapped in `{context, value}`.
  - `option 1` (object[], optional)
    - `pubkey` (string, required): Account address, base-58 encoded.
    - `account` (object, required)
      - `lamports` (integer, optional)
      - `owner` (string, optional)
      - `executable` (boolean, optional)
      - `rentEpoch` (integer, optional)
      - `space` (integer, optional)
      - `data` (any, optional): Same shape as `getAccountInfo`.
  - `option 2` (object, optional)
    - `context` (object, optional)
      - `slot` (integer, optional)
      - `apiVersion` (string, optional)
    - `value` (object[], optional)

## Example: All Token Program accounts for one owner, holding one specific mint

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": "getProgramAccounts",
    "params": [
      "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
      {
        "encoding": "jsonParsed",
        "filters": [
          { "dataSize": 165 },
          {
            "memcmp": {
              "offset": 32,
              "bytes": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
            }
          },
          {
            "memcmp": {
              "offset": 64,
              "bytes": "HwfP9khbHJgWwnWB9Ai3DVCe8RWjCJUyYQETMnpxZ6YQ"
            }
          }
        ]
      }
    ]
  }'
```

Response:

```json
{
  "jsonrpc": "2.0",
  "result": [
    {
      "pubkey": "Gwu5KZVYZpSHuPgKb3ypEVgUTpp2kU5jSnPdSo3N23kS",
      "account": {
        "data": {
          "parsed": {
            "info": {
              "isNative": false,
              "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
              "owner": "HwfP9khbHJgWwnWB9Ai3DVCe8RWjCJUyYQETMnpxZ6YQ",
              "state": "initialized",
              "tokenAmount": {
                "amount": "6321160855",
                "decimals": 6,
                "uiAmount": 6321.160855,
                "uiAmountString": "6321.160855"
              }
            },
            "type": "account"
          },
          "program": "spl-token",
          "space": 165
        },
        "executable": false,
        "lamports": 2039280,
        "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
        "rentEpoch": 18446744073709552000,
        "space": 165
      }
    }
  ],
  "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 `getProgramAccounts requires higher tier`.
- A typical filter combines `dataSize` with one or more `memcmp` clauses; constant-k rejects an unfiltered scan outright rather than throttling it.
- The example's byte offsets (`mint` at 32, `owner` at 64) match the classic SPL Token account struct; Token-2022 accounts share this base layout but can be longer with extensions, so a bare `dataSize: 165` filter misses them.
- `getProgramAccountsV2` (paginated, up to 10,000 accounts per page, Blade Runner and Nexus) pages through a large account set instead of filtering a single call.
- Twelve hot programs are answered from a purpose-built in-memory index rather than a live disk scan: a fraction of a second, no scan thread, and no filter required. The validator's scan-results cap does not apply to them; the index bounds the answer to 100,000 accounts, and broader results page through getProgramAccountsV2. Every other program is scanned on disk, where a selective filter is required and the validator's scan-results cap bounds the answer.

| 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` |

