Solana accounts store all raw data on the blockchain. This guide demonstrates how to efficiently retrieve account data using Helius APIs.

Using RPC Methods

The most direct way to read account data is through Solana RPC methods:

// Replace YOUR_API_KEY with the API key from your Helius dashboard
const response = await fetch(`https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY`, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    jsonrpc: "2.0",
    id: "1",
    method: "getAccountInfo",
    params: ["83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri", { encoding: "jsonParsed" }],
  }),
});
const data = await response.json();
console.log("Account data:", data.result.value);

API Reference

getAccountInfo

Common Parameters

  • encoding: Choose from base58, base64, or jsonParsed (recommended)
  • commitment: Data consistency level (processed, confirmed, or finalized)
  • dataSlice: Fetch only a specific portion of the account data

Getting Multiple Accounts

For batch retrieval, use getMultipleAccounts:

const response = await fetch('https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: '1',
    method: 'getMultipleAccounts',
    params: [
      ['83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri', 'SysvarC1ock11111111111111111111111111111111', 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'],
      { encoding: 'jsonParsed' }
    ]
  })
});
const data = await response.json();
console.log("Multiple accounts data:", data.result.value);

API Reference

getMultipleAccounts

Best Practices

  • Use account subscriptions via WebSockets for real-time updates
  • For large-scale data needs, consider using the Helius DAS API or LaserStream
  • Cache account data when appropriate to reduce API calls