Documentation index

getTokenAccountsByOwner

Returns all SPL Token accounts owned by a specified address. This is the standard method for loading a user's complete token portfolio -- it returns every token account the user owns, optionally filtered by mint or token program. Wallets, portfolio trackers, and DeFi applications use this extensively to display token holdings, and it supports the jsonParsed encoding for human-readable token data.

Parameters

#TypeRequiredDescription
1stringYesBase-58 encoded public key of the account owner
2objectYesFilter object -- must contain either mint or programId
3objectNoConfiguration object

Configuration object fields:

FieldTypeDescription
mintstringFilter by SPL Token mint address (base-58)
programIdstringFilter by SPL Token program ID (base-58)
encodingstringData encoding: base64, base64+zstd, or jsonParsed
commitmentstringCommitment level: processed, confirmed, or finalized
dataSliceobjectLimit returned data: { offset: number, length: number }
minContextSlotnumberMinimum slot at which the request can be evaluated

Response

Returns an RpcResponse with an array of token account objects:

FieldTypeDescription
context.slotu64The slot at which the value was read
value[].pubkeystringToken account address (base-58)
value[].account.dataobjectToken account data in the requested encoding
value[].account.lamportsu64Lamports in the token account
value[].account.ownerstringToken program ID

Code Examples

cURL

Terminal
curl http://88.216.36.108:7999 -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getTokenAccountsByOwner",
  "params": [
    "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
    { "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" },
    { "encoding": "jsonParsed" }
  ]
}'

TypeScript

TypeScript
const response = await fetch("http://88.216.36.108:7999", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    jsonrpc: "2.0",
    id: 1,
    method: "getTokenAccountsByOwner",
    params: [
      "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
      { programId: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" },
      { encoding: "jsonParsed" }
    ]
  }),
});
const { result } = await response.json();
console.log("Token accounts:", result.value.length);

Python

Python
import requests

response = requests.post("http://88.216.36.108:7999", json={
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getTokenAccountsByOwner",
    "params": [
        "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
        {"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},
        {"encoding": "jsonParsed"}
    ]
})
result = response.json()["result"]
print(f"Token accounts: {len(result['value'])}")

Rust

Rust
use reqwest::Client;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    let res = client.post("http://88.216.36.108:7999")
        .json(&json!({
            "jsonrpc": "2.0",
            "id": 1,
            "method": "getTokenAccountsByOwner",
            "params": [
                "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
                {"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},
                {"encoding": "jsonParsed"}
            ]
        }))
        .send().await?
        .text().await?;
    println!("{}", res);
    Ok(())
}

Example Response

JSON
{
  "jsonrpc": "2.0",
  "result": {
    "context": { "slot": 166974442 },
    "value": [
      {
        "pubkey": "CnPoSPKXu7wJqxe59Fs72tkBeALovhsCxYeFwPCQH9TD",
        "account": {
          "data": { "parsed": { "type": "account", "info": { "tokenAmount": { "amount": "1000000", "decimals": 6, "uiAmount": 1.0 } } }, "program": "spl-token", "space": 165 },
          "executable": false,
          "lamports": 2039280,
          "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
        }
      }
    ]
  },
  "id": 1
}