API & Developers

Crypto Portfolio API: A Practical Guide

What a crypto portfolio API returns, how to fetch multi-chain balances, DeFi positions and transaction history from one, and the mistakes to avoid.

Octav Team2 min read
Banner: Pull a multi-chain portfolio in one request

Most teams that end up buying portfolio data start by trying to build it. The build usually stalls at the same place: enumerating positions is easy on one chain and miserable on fifteen.

What a portfolio API actually has to return

A wallet address is not a portfolio. A useful response resolves an address into every position it controls, priced and categorised:

FieldWhy it matters
chainPositions must be attributable per network
protocolAn LP token is meaningless without its protocol context
balanceRaw units, so you can re-derive value yourself
valuePriced at a stated timestamp, not "now"
categoryWallet, lending, staking, LP, vesting

The last two are what separate a portfolio API from a block explorer. A balance without a timestamped price is not something you can put in a report.

Fetching a portfolio

A single request should resolve an address across every supported chain:

curl -s https://api.octav.fi/v1/portfolio \
  -H "Authorization: Bearer $OCTAV_API_KEY" \
  -G --data-urlencode "addresses=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"

Handling the response in TypeScript:

type Position = {
  chain: string;
  protocol: string | null;
  symbol: string;
  balance: string;
  value: number;
  category: "wallet" | "lending" | "staking" | "lp" | "vesting";
};
 
const res = await fetch(url, {
  headers: { Authorization: `Bearer ${process.env.OCTAV_API_KEY}` },
});
 
if (!res.ok) {
  throw new Error(`Portfolio request failed: ${res.status}`);
}
 
const { positions } = (await res.json()) as { positions: Position[] };
 
// Exposure by chain — the aggregate most teams want first.
const byChain = positions.reduce<Record<string, number>>((acc, p) => {
  acc[p.chain] = (acc[p.chain] ?? 0) + p.value;
  return acc;
}, {});

Three mistakes that show up in production

  • Treating the response as live state. Prices move. Store the timestamp alongside the value, or your reports will not reconcile with each other.
  • Summing LP tokens at face value. An LP position's value is a function of the pool's composition, not of the token's own price.
  • Paginating naively. Addresses with long histories return large result sets; handle the cursor rather than assuming one page.

Where to go next

Octav returns this shape for the most complete set of positions of any provider we have measured: it matches DeBank's EVM DeFi depth and adds the protocols most others miss — options, perps, Derive and Solana DeFi — so the number is right on a real multi-chain wallet, not just a spot one. See the nine-provider benchmark and how to choose a crypto portfolio API.

From here, depending on what you need next:

If you wantGo to
Every endpoint, parameter and credit costEndpoint reference
To evaluate providers before committingHow to choose a crypto portfolio API
Measured coverage across nine providersThe benchmark
A working front end on top of this dataBuild a portfolio dashboard
Why two APIs report different net worthWhy portfolio APIs disagree
An agent to consume itAI agent tools for portfolio data
The EVM side, where chain count is the difficultyEVM portfolio API guide
The Solana side, where program decoding isSolana portfolio API guide

The API documentation covers authentication, rate limits and the full response schema.

Keep reading

  • Banner: How to choose a crypto portfolio API
    API & Developers

    How to Choose a Crypto Portfolio API

    A buyer's guide to evaluating crypto portfolio APIs — the tests to run, the questions vendors dislike, and the trade-offs between coverage, cost and latency.

    3 min read

  • Banner: Every Octav API endpoint, with credits and limits
    API & Developers

    Crypto Portfolio API Endpoint Reference

    Every Octav API endpoint with its parameters, credit cost and response, plus authentication, rate limits and caching behaviour for building on portfolio data.

    2 min read