Skip to main content
GET
/
api
/
:projectId
/
accounts
Project Accounts
curl --request GET \
  --url https://api.example.com/api/:projectId/accounts
{
  "projectId": "<string>",
  "programName": "<string>",
  "accounts": [
    {
      "name": "<string>",
      "kind": "<string>",
      "docs": [
        {}
      ],
      "discriminator": [
        {}
      ],
      "fields": [
        {
          "name": "<string>",
          "type": "<string>"
        }
      ]
    }
  ]
}

Overview

Accounts represent the on-chain data structures stored by your Solana program. These endpoints allow you to retrieve the complete schema for all account types defined in the program’s IDL.

List All Accounts

GET /api/:projectId/accounts
Retrieve all account type definitions from the program’s IDL, including their fields and discriminators.

Path Parameters

projectId
string
required
The unique identifier of the project

Response

projectId
string
The project identifier
programName
string
Name of the Anchor program from the IDL
accounts
array
List of account type definitions

Example Request

curl -X GET "https://api.orquestra.so/api/proj_abc123/accounts"

Example Response

{
  "projectId": "proj_abc123",
  "programName": "token_swap",
  "accounts": [
    {
      "name": "Pool",
      "kind": "struct",
      "docs": [
        "Token swap pool account",
        "Stores liquidity and swap configuration"
      ],
      "discriminator": [241, 154, 109, 4, 17, 177, 109, 188],
      "fields": [
        {
          "name": "authority",
          "type": "publicKey"
        },
        {
          "name": "tokenA",
          "type": "publicKey"
        },
        {
          "name": "tokenB",
          "type": "publicKey"
        },
        {
          "name": "reserveA",
          "type": "u64"
        },
        {
          "name": "reserveB",
          "type": "u64"
        },
        {
          "name": "fee",
          "type": "u16"
        },
        {
          "name": "minLiquidity",
          "type": "u64"
        },
        {
          "name": "maxSlippage",
          "type": "u16"
        },
        {
          "name": "paused",
          "type": "bool"
        },
        {
          "name": "createdAt",
          "type": "i64"
        },
        {
          "name": "updatedAt",
          "type": "i64"
        }
      ]
    },
    {
      "name": "UserPosition",
      "kind": "struct",
      "docs": [
        "User liquidity position"
      ],
      "discriminator": [45, 78, 201, 123, 88, 34, 190, 77],
      "fields": [
        {
          "name": "owner",
          "type": "publicKey"
        },
        {
          "name": "pool",
          "type": "publicKey"
        },
        {
          "name": "liquidity",
          "type": "u64"
        },
        {
          "name": "depositedA",
          "type": "u64"
        },
        {
          "name": "depositedB",
          "type": "u64"
        },
        {
          "name": "lastDepositAt",
          "type": "i64"
        }
      ]
    },
    {
      "name": "GlobalConfig",
      "kind": "struct",
      "docs": [
        "Global program configuration"
      ],
      "discriminator": [89, 12, 45, 234, 156, 78, 91, 200],
      "fields": [
        {
          "name": "admin",
          "type": "publicKey"
        },
        {
          "name": "treasuryFee",
          "type": "u16"
        },
        {
          "name": "treasury",
          "type": "publicKey"
        },
        {
          "name": "paused",
          "type": "bool"
        },
        {
          "name": "minPoolLiquidity",
          "type": "u64"
        },
        {
          "name": "maxPoolCount",
          "type": "u32"
        }
      ]
    }
  ]
}

Understanding Account Discriminators

Anchor programs use 8-byte discriminators to identify account types. The discriminator is stored as the first 8 bytes of the account data and is derived from a hash of the account type name.
import { AccountInfo } from '@solana/web3.js';

// Pool account discriminator
const POOL_DISCRIMINATOR = [241, 154, 109, 4, 17, 177, 109, 188];

function isPoolAccount(accountInfo: AccountInfo<Buffer>): boolean {
  const discriminator = accountInfo.data.slice(0, 8);
  return discriminator.equals(Buffer.from(POOL_DISCRIMINATOR));
}

Deserializing Account Data

Once you’ve identified an account type using its discriminator, you can deserialize the remaining data according to the field schema.
import { Program } from '@project-serum/anchor';
import { Connection, PublicKey } from '@solana/web3.js';

// Fetch and deserialize a Pool account
const connection = new Connection('https://api.mainnet-beta.solana.com');
const poolAddress = new PublicKey('...');

const poolAccount = await program.account.pool.fetch(poolAddress);
console.log('Reserve A:', poolAccount.reserveA.toString());
console.log('Reserve B:', poolAccount.reserveB.toString());

Error Responses

{
  "error": "Project not found or not public"
}
The specified project ID does not exist, is private, or has no IDL uploaded.
{
  "error": "Failed to get accounts"
}
The server encountered an error processing the request.

Notes

No authentication required - This endpoint is public for all public projects.
Use the discriminator values to filter and identify account types when fetching accounts using getProgramAccounts.
Field types are resolved recursively. Complex types like vec<CustomStruct> will show the full type representation including nested structures.
Account data size is determined by the sum of all field sizes plus the 8-byte discriminator. Ensure your rent calculations account for the full data size.

Build docs developers (and LLMs) love