getAccountInfo
Returns all information associated with the account of provided Pubkey
Common use cases
| Validate Token Account Before Transfer | Fetch token account to verify ownership by TOKEN_PROGRAM_ID and parse balance before initiating SPL token transfer. Prevents failed transactions from invalid accounts. |
| Check Program-Derived Address (PDA) Existence | Verify a PDA has been initialized before reading its state. Returns null if account doesn't exist, avoiding unnecessary transaction failures. |
| Fetch NFT Metadata Account | Retrieve metadata account using jsonParsed encoding for known Metaplex program accounts. Avoids manual deserialization for standard NFT data structures. |
| Optimize Large Account Fetching with dataSlice | Request only needed bytes from large program accounts (e.g., orderbook, AMM pool state). Reduces bandwidth and speeds up queries for accounts with 10KB+ data. |
| Monitor Account Updates with Commitment Levels | Use processed commitment for real-time UI updates, confirmed for transaction validation, finalized for permanent state. Balances speed vs. finality guarantees. |
Parameters
pubkey (string, required)
Pubkey of account to query, as base-58 encoded string.
config (object, optional)
Configuration object.
Fields:
commitment(string): The commitment describes how finalized a block is at that point in time. See Configuring State Commitment.encoding(string): Encoding format for Account data. See Parsed Responses.base58is slow and limited to less than 129 bytes of Account data.base64will return base64 encoded data for Account data of any size.base64+zstdcompresses the Account data using Zstandard and base64-encodes the result.binary(⚠️ deprecated) is similar tobase58, except data will be a base58-encoded string and not an array that includes the encoding.jsonParsedencoding attempts to use program-specific state parsers to return more human-readable and explicit account state data.- If
jsonParsedis requested but a parser cannot be found, the field falls back tobase64encoding, detectable when thedatafield is typestring.
dataSlice(object): Request a slice of the account's data.length: <usize>- number of bytes to returnoffset: <usize>- byte offset from which to start reading Data slicing is only available forbase58,base64, orbase64+zstdencodings.
minContextSlot(string): The minimum slot that the request can be evaluated at.
Request
- cURL
- JavaScript
- Python
curl https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [
"vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
{
"commitment": "finalized",
"encoding": "base58"
}
]
}'
// Using fetch
const response = await fetch('https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [
"vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
{
"commitment": "finalized",
"encoding": "base58"
}
]
})
});
const data = await response.json();
console.log(data);
import requests
import json
url = 'https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY'
headers = {'Content-Type': 'application/json'}
data = {
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [
"vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
{
"commitment": "finalized",
"encoding": "base58"
}
]
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
Replace mainnet with devnet in the URL to query devnet instead.
Response
{
"jsonrpc": "2.0",
"result": {
"context": { "apiVersion": "2.0.15", "slot": 341197053 },
"value": {
"data": ["", "base58"],
"executable": false,
"lamports": 88849814690250,
"owner": "11111111111111111111111111111111",
"rentEpoch": 18446744073709551615,
"space": 0
}
},
"id": 1
}
Response Fields
data (string | [string,encoding] | object)
Data associated with the account. Format depends on encoding parameter:
- If the encoding parameter is left as the deprecated default of
binary, this will be a string containing encoded binary data. - If
base58,base64, orbase64+zstdis specified, this will be an array, where the first element is the encoded data string and the second element is the encoding format. - If
jsonParsedis specified, this will be JSON format{<program>: <state>}.
executable (bool)
Boolean indicating if the account contains a program (and is strictly read-only)
lamports (u64)
Number of lamports assigned to this account
owner (string)
base-58 encoded Pubkey of the program this account has been assigned to
rentEpoch (u64)
The epoch at which this account will next owe rent, as u64
space (u64)
The data size of the account
FAQ and Troubleshooting
Why does getAccountInfo return null?
The account doesn't exist on-chain. This is expected behavior for unfunded accounts, closed accounts, or invalid addresses. Check if the account has been initialized before attempting to read its data.
Which encoding should I use for program account data?
Use base64 (default) for custom program data that you'll deserialize yourself. Use jsonParsed only for known program types (Token, NFT metadata) that Solana can parse automatically. Use base64+zstd for large accounts to reduce bandwidth.
What causes 'Expected buffer length X isn't within bounds' errors?
This error occurs when your deserialization code expects a different data structure than what's stored. Ensure the account was serialized with the same method (Borsh, Anchor, etc.) and version that you're using to deserialize it.
When should I use the dataSlice parameter?
Use dataSlice when you only need part of a large account's data (>1KB). For example, fetching just a market's header from a 10KB orderbook account. This reduces RPC response time and bandwidth costs.
What's the difference between commitment levels for getAccountInfo?
processed (fastest, may reorg), confirmed (supermajority vote, ~1s latency), finalized (permanent, ~2-3s latency). Use processed for UI updates, confirmed for transaction validation, finalized for permanent records.
Related Methods
getMultipleAccounts
Fetch multiple accounts in a single RPC call. More efficient than multiple getAccountInfo requests when checking 5+ accounts. Use for portfolio overviews or bulk validation.
accountSubscribe (WebSocket)
Subscribe to real-time account updates via WebSocket. Use instead of polling getAccountInfo when monitoring account state changes (e.g., balance updates, program state changes).
getProgramAccounts
Fetch all accounts owned by a specific program with optional filters. Use for discovery (finding all token accounts for a wallet) instead of calling getAccountInfo on known addresses.
getBalance
Lightweight alternative when you only need an account's SOL balance. Returns lamports count without data, owner, or encoding overhead. Use for simple balance checks.
getTokenAccountBalance
Specialized method for SPL token account balances. Returns parsed amount with decimals. Use instead of getAccountInfo + manual deserialization for token balance queries.
External Resources
- Solana Official Documentation
- Solana Commitment Levels Explained - Official documentation explaining processed, confirmed, and finalized commitment levels. Essential for understanding data consistency guarantees when using getAccountInfo.
- Account Model Documentation - Core concepts for Solana accounts: owner, data, lamports, executable flag, rent. Provides context for interpreting getAccountInfo response fields.
- RPC Encoding Formats - Official guide to encoding options (base58, base64, base64+zstd, jsonParsed) with performance characteristics and use cases.