# getTokenAccountsByOwnerAtSlot

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://solana-mainnet.g.alchemy.com/v2/{apiKey}

Returns every SPL Token and Token-2022 account owned by a wallet as of a specific slot. It is the historical, point-in-time version of Solana's `getTokenAccountsByOwner`: the same inputs, plus an optional `slot` to look up the past and `pageKey` / `pageLimit` to page through large wallets.

If you omit `slot`, the call returns the wallet's current token accounts (as of the latest available slot). Responses are always `jsonParsed`.

Reference: https://www.alchemy.com/docs/chains/solana/solana-api-endpoints/get-token-accounts-by-owner-at-slot

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Token owner Pubkey | string | Yes | The base58-encoded Pubkey of the wallet whose token accounts you want. |
| Token filter | object | No | Restricts results to a single mint or a single token program. Include either `mint` or `programId`, never both. Omit to return all token accounts. |
| Configuration | object | No | Optional point-in-time (`slot`) and pagination (`pageKey`, `pageLimit`) options. |

## Result

**Token accounts at slot** (object): A paginated set of the token accounts the wallet held at the requested slot, plus the slot the result was computed at and a `pageKey` cursor for the next page (or `null` on the last page).

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "getTokenAccountsByOwnerAtSlot",
  "params": [
    "GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q",
    {
      "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
    },
    {
      "slot": 250000000,
      "pageLimit": 1000
    }
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "apiVersion": "2.3.3",
      "slot": 250000000
    },
    "value": [
      {
        "pubkey": "3emsAVdmGKERbHjmGfQ6oZ1e35dkf5iYcS6U4CPKFVaa",
        "account": {
          "lamports": 2039280,
          "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
          "executable": false,
          "rentEpoch": 18446744073709552000,
          "space": 165,
          "data": {
            "program": "spl-token",
            "space": 165,
            "parsed": {
              "type": "account",
              "info": {
                "isNative": false,
                "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
                "owner": "GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q",
                "state": "initialized",
                "tokenAmount": {
                  "amount": "1500000",
                  "decimals": 6,
                  "uiAmount": 1.5,
                  "uiAmountString": "1.5"
                }
              }
            }
          }
        }
      }
    ],
    "pageKey": null
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://solana-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getTokenAccountsByOwnerAtSlot",
  "params": [
    "GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q",
    {
      "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
    },
    {
      "slot": 250000000,
      "pageLimit": 1000
    }
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'getTokenAccountsByOwnerAtSlot',
    params: [
      'GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q',
      {mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'},
      {slot: 250000000, pageLimit: 1000}
    ]
  })
};

fetch('https://solana-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://solana-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getTokenAccountsByOwnerAtSlot",
    "params": [
        "GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q",
        { "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" },
        {
            "slot": 250000000,
            "pageLimit": 1000
        }
    ]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://solana-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"getTokenAccountsByOwnerAtSlot\",\n  \"params\": [\n    \"GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q\",\n    {\n      \"mint\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\"\n    },\n    {\n      \"slot\": 250000000,\n      \"pageLimit\": 1000\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://solana-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"getTokenAccountsByOwnerAtSlot\",\n  \"params\": [\n    \"GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q\",\n    {\n      \"mint\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\"\n    },\n    {\n      \"slot\": 250000000,\n      \"pageLimit\": 1000\n    }\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://solana-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"getTokenAccountsByOwnerAtSlot\",\n  \"params\": [\n    \"GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q\",\n    {\n      \"mint\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\"\n    },\n    {\n      \"slot\": 250000000,\n      \"pageLimit\": 1000\n    }\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: getTokenAccountsByOwnerAtSlot
summary: Returns every SPL Token and Token-2022 account owned by a wallet as of a specific slot.
description: |-
  Returns every SPL Token and Token-2022 account owned by a wallet as of a specific slot. It is the historical, point-in-time version of Solana's `getTokenAccountsByOwner`: the same inputs, plus an optional `slot` to look up the past and `pageKey` / `pageLimit` to page through large wallets.

  If you omit `slot`, the call returns the wallet's current token accounts (as of the latest available slot). Responses are always `jsonParsed`.
x-compute-units: 40
params:
  - name: Token owner Pubkey
    required: true
    description: The base58-encoded Pubkey of the wallet whose token accounts you want.
    schema:
      title: Pubkey
      type: string
      description: Base-58 encoded public key.
  - name: Token filter
    required: false
    description: Restricts results to a single mint or a single token program. Include either `mint` or `programId`, never both. Omit to return all token accounts.
    schema:
      title: GetTokenAccountsByOwnerAtSlot Filter
      type: object
      description: Restricts results to a single mint or a single token program. Include either `mint` or `programId`, never both. Omit the whole object to return all token accounts.
      properties:
        mint:
          title: Pubkey
          type: string
          description: Return only accounts of this token mint (base58 pubkey).
        programId:
          title: Pubkey
          type: string
          description: Return only accounts owned by this token program. Must be `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA` (SPL Token) or `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb` (Token-2022).
  - name: Configuration
    required: false
    description: Optional point-in-time (`slot`) and pagination (`pageKey`, `pageLimit`) options.
    schema:
      title: GetTokenAccountsByOwnerAtSlot Configuration
      type: object
      description: Optional point-in-time and pagination options.
      properties:
        slot:
          type: integer
          description: The slot to reconstruct the wallet's holdings at. Omit for the wallet's current holdings (as of the latest available slot).
        pageKey:
          type: string
          default: ''
          description: Cursor for the next page. Use the `pageKey` from the previous response; omit or send an empty string for the first page.
        pageLimit:
          type: integer
          default: 1000
          maximum: 10000
          description: Maximum number of token accounts per page. Values above `10000` are reduced to `10000`.
        encoding:
          description: Accepted for compatibility; responses are always `jsonParsed`.
          title: Data Encoding
          type: string
          enum:
            - base58
            - base64
            - base64+zstd
            - jsonParsed
examples:
  - name: getTokenAccountsByOwnerAtSlot example
    params:
      - name: Token owner Pubkey
        value: GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q
      - name: Token filter
        value:
          mint: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
      - name: Configuration
        value:
          slot: 250000000
          pageLimit: 1000
    result:
      name: Token accounts at slot
      value:
        context:
          apiVersion: 2.3.3
          slot: 250000000
        value:
          - pubkey: 3emsAVdmGKERbHjmGfQ6oZ1e35dkf5iYcS6U4CPKFVaa
            account:
              lamports: 2039280
              owner: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
              executable: false
              rentEpoch: 18446744073709552000
              space: 165
              data:
                program: spl-token
                space: 165
                parsed:
                  type: account
                  info:
                    isNative: false
                    mint: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                    owner: GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q
                    state: initialized
                    tokenAmount:
                      amount: '1500000'
                      decimals: 6
                      uiAmount: 1.5
                      uiAmountString: '1.5'
        pageKey: null
result:
  name: Token accounts at slot
  description: A paginated set of the token accounts the wallet held at the requested slot, plus the slot the result was computed at and a `pageKey` cursor for the next page (or `null` on the last page).
  schema:
    title: GetTokenAccountsByOwnerAtSlot Result
    type: object
    description: A paginated set of token accounts held by the owner at the requested slot.
    properties:
      context:
        type: object
        description: The slot the result was computed at.
        properties:
          slot:
            type: integer
            description: The slot the result was computed at (the `slot` you requested, or the latest slot).
          apiVersion:
            type: string
            description: API version string.
      value:
        type: array
        description: The token accounts the wallet held at that slot, decoded in `jsonParsed` form.
        items:
          title: Parsed Token Account
          type: object
          description: A single SPL Token or Token-2022 account with its data decoded in `jsonParsed` form.
          properties:
            pubkey:
              title: Pubkey
              type: string
              description: The token account Pubkey as a base-58 encoded string.
            account:
              title: Parsed Token Account Info
              type: object
              description: Account metadata plus the `jsonParsed` token account payload.
              properties:
                lamports:
                  type: integer
                  description: Number of lamports assigned to this account.
                owner:
                  title: Pubkey
                  type: string
                  description: The token program that owns this account (SPL Token or Token-2022).
                executable:
                  type: boolean
                  description: Indicates if the account contains a program.
                rentEpoch:
                  type: integer
                  description: The epoch at which this account will next owe rent.
                space:
                  type: integer
                  description: On-chain data size in bytes.
                data:
                  title: Parsed SPL Token Account Data
                  type: object
                  description: '`jsonParsed` decoding of a token account''s on-chain data. The outer envelope carries the parser identity; the actual account fields live under `parsed.info`.'
                  properties:
                    program:
                      type: string
                      description: The program the parser used to decode this account (`spl-token` or `spl-token-2022`).
                    space:
                      type: integer
                      description: On-chain data size in bytes.
                    parsed:
                      type: object
                      description: The parsed account payload.
                      properties:
                        type:
                          type: string
                          description: The parsed record type (e.g., `account`).
                        info:
                          title: Parsed SPL Token Account Info
                          type: object
                          description: '`jsonParsed` decoding of an SPL Token or Token-2022 account''s data.'
                          properties:
                            isNative:
                              type: boolean
                              description: '`true` when this token account is the native SOL mint wrapper.'
                            mint:
                              title: Pubkey
                              type: string
                              description: The mint associated with this token account.
                            owner:
                              title: Pubkey
                              type: string
                              description: The wallet that owns this token account.
                            state:
                              type: string
                              description: Account state, typically `initialized`, `uninitialized`, or `frozen`.
                            tokenAmount:
                              title: Token Balance
                              type: object
                              description: The token balance held by this account.
                              properties:
                                amount:
                                  type: string
                                  description: The raw balance without decimals, a string representation of u64.
                                decimals:
                                  type: integer
                                  description: Number of base-10 digits to the right of the decimal place.
                                uiAmount:
                                  type: number
                                  nullable: true
                                  description: The balance, using mint-prescribed decimals. **DEPRECATED**
                                uiAmountString:
                                  type: string
                                  description: The balance as a string, using mint-prescribed decimals.
      pageKey:
        type: string
        nullable: true
        description: Cursor for the next page, or `null` on the last page. Send it back in `config.pageKey` to continue paging.
errors:
  - code: -32602
    message: Invalid params. Common causes include a missing or malformed `owner`, sending both `mint` and `programId` in the filter, a `programId` that is not the SPL Token or Token-2022 program, an invalid `pageKey` cursor, or the latest slot being temporarily unavailable when `slot` is omitted.
  - code: -32601
    message: Method not found.
  - code: -32603
    message: Internal error. Retry the request; if it persists, contact support.
```
