Skip to main content
TL;DR: New POST /wallet/position batch endpoint - fetch up to 100 positions in one request with optimized Solana getMultipleAccounts.

Batch Wallet Positions Endpoint

New batch mode for the wallet/position endpoint, allowing you to fetch multiple positions across different wallets and assets in a single API call.

Why Batch?

Use CaseBeforeAfter
Fetch 50 positions50 API calls1 API call
Solana RPC overheadN calls to getTokenAccountsByOwner1 call to getMultipleAccounts
Rate limit consumption50 credits1 credit

New POST Endpoint

POST /api/2/wallet/position
Content-Type: application/json

{
  "items": [
    { "wallet": "F9cT...a4F2", "blockchain": "Solana", "asset": "HHvQ...pump" },
    { "wallet": "Fw6h...Q6SjW", "blockchain": "Solana", "asset": "6sBB...pump" },
    // ... up to 100 items
  ]
}

Response Format

Each item in the response now includes a wallet field for easy identification:
{
  "payload": [
    {
      "wallet": "F9cT...a4F2",
      "token": { /* token details */ },
      "balance": 1234.56,
      "rawBalance": "1234560000",
      "amountUSD": 45.67,
      "buys": 5,
      "sells": 2,
      "realizedPnlUSD": 12.34,
      "unrealizedPnlUSD": 5.67,
      "totalPnlUSD": 18.01
      // ... other fields
    },
    // ... other positions
  ]
}

SDK Support

Both TypeScript SDK methods are now available:
import { Mobula } from '@mobula/sdk';

const mobula = new Mobula({ apiKey: 'your-key' });

// Single position (GET)
const single = await mobula.fetchWalletPosition({
  wallet: 'F9cT...a4F2',
  blockchain: 'Solana',
  asset: 'HHvQ...pump'
});

// Batch positions (POST)
const batch = await mobula.fetchWalletPositionBatch({
  items: [
    { wallet: 'F9cT...a4F2', blockchain: 'Solana', asset: 'HHvQ...pump' },
    { wallet: 'Fw6h...Q6SjW', blockchain: 'Solana', asset: '6sBB...pump' },
  ]
});

Performance Optimizations

  • Single SQL query using UNION ALL instead of N individual queries
  • Batched token data fetched in one database call
  • Solana: Uses getMultipleAccounts for all SPL tokens (100 accounts per RPC call)
  • Parallel execution of native SOL and SPL token balance fetches
The batch endpoint is optimized for Solana tokens. EVM chain balance fetching will be added in a future update.

SDK Updates

@mobula_labs/types v0.1.2

New schemas for batch wallet positions:
  • SinglePositionBatchParamsSchema - Batch request validation
  • SinglePositionBatchResponseSchema - Batch response validation
  • batchPositionItemSchema - Position item with wallet field
  • Type aliases: WalletPositionParams, WalletPositionResponse, WalletPositionBatchParams, WalletPositionBatchResponse

@mobula/sdk v0.1.2

New methods:
  • fetchWalletPosition(params) - GET single position
  • fetchWalletPositionBatch(params) - POST batch positions