Tutorials3 min read

Build a multi-chain crypto portfolio tracker

Track balances across Ethereum, BNB, Bitcoin and Tron and sum a live USD total with a single non-custodial API.

cryptoapi team
Tutorials
On this page

A portfolio tracker is one of the cleanest things to build on CryptoAPI: you read public addresses, get a USD value back inline, and never touch a private key or run a node. Here is how to assemble a multi-chain view across Ethereum, BNB Smart Chain, Bitcoin and Tron, then refresh it on a timer.

Every /api/* call needs an API key, sent as a key header, or an Authorization: Bearer JWT. Grab a key in the dashboard and you are ready.

Step 1: Read each address with one balance call

For every wallet your user holds, call POST /api/wallet/balance with the network and address. The response includes the native coin plus any tokens you request, and each entry already carries a usdValue, so there is no separate price lookup.

bash
curl -X POST https://api.cryptoapi.so/api/wallet/balance \
  -H "key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "network": "ethereum",
    "address": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
    "tokens": ["0xdac17f958d2ee523a2206206994597c13d831ec7"]
  }'
json
{
  "success": true,
  "data": [
    {
      "name": "Ethereum",
      "symbol": "ETH",
      "balance": "1.482",
      "decimals": 18,
      "isToken": false,
      "usdValue": 5340.18
    },
    {
      "name": "Tether USD",
      "symbol": "USDT",
      "balance": "250.00",
      "decimals": 6,
      "isToken": true,
      "usdValue": 250.0
    }
  ]
}

You can pass the native coin plus up to 20 token contracts per call. Repeat the request per network by swapping network to bnb, bitcoin or tron and supplying that chain's address.

Step 2: Aggregate usdValue across chains

Because usdValue is already in the payload, the portfolio total is just a sum. Fan the requests out, then reduce every entry from every chain into one number.

javascript
const wallets = [
  { network: "ethereum", address: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e" },
  { network: "bnb",      address: "0x8894E0a0c962CB723c1976a4421c95949bE2D4E3" },
  { network: "bitcoin",  address: "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq" },
  { network: "tron",     address: "TJYeasTPa6gpEEfYYT8gEPK8Z9zFVQ12Jj" },
];

const results = await Promise.all(
  wallets.map((w) =>
    fetch("https://api.cryptoapi.so/api/wallet/balance", {
      method: "POST",
      headers: { key: process.env.API_KEY, "Content-Type": "application/json" },
      body: JSON.stringify(w),
    }).then((r) => r.json())
  )
);

const total = results
  .flat()
  .reduce((sum, asset) => sum + (asset.usdValue ?? 0), 0);

That total is your live portfolio value in USD across all four chains.

Step 3: Enrich the UI and show recent activity

To render tickers, logos and rates for coins your user does not hold yet, or to power a supported-assets picker, call the public, no-auth endpoint:

bash
curl "https://api.cryptoapi.so/api/info/supported-coins?network=bnb" \
  --header "key: $CRYPTOAPI_KEY"

Each coin comes back with name, symbol, decimals, logo, contractAddress and a usdRate refreshed about once a minute.

Want a recent-activity feed per address? Query the indexed history:

bash
curl "https://api.cryptoapi.so/api/blockchain/transactions?network=ethereum&address=0x742d35Cc6634C0532925a3b844Bc454e4438f44e&limit=25&sortBy=timestamp&sortOrder=desc" \
  -H "key: YOUR_API_KEY"

Note that network is required, and this endpoint serves up to 30 days of live indexed transactions, which is ideal for a recent-transfers panel rather than a full archival ledger.

Keeping it fresh

CryptoAPI has no webhooks or streaming, so refresh by polling. Re-run the Step 1 and Step 2 calls on an interval (every 30 to 60 seconds is a sensible balance between freshness and request volume) and re-render the total. Since usdRate on supported-coins updates roughly every minute, a one-minute cadence keeps fiat values current without hammering the API.

That is the whole tracker: balances in, usdValue summed, no nodes, no key custody. Grab an API key in the dashboard and read the full reference at https://api.cryptoapi.so/api/doc.

Read it, then ship it

Copy the code above and run it today.

Every snippet in this guide works on the free plan. Grab a key and make your first call in a minute.