GET
/
getPortfolios
import { setOnchainKitConfig } from '@coinbase/onchainkit';
import { getPortfolios } from '@coinbase/onchainkit/api';

setOnchainKitConfig({ apiKey: 'YOUR_API_KEY' });

const response = await getPortfolios({
  addresses: ['0x...'],
});
{
  "portfolios": [
    {
      "address": "0x...",
      "portfolioBalanceInUsd": 100,
      "tokenBalances": [
        {
          "address": "0x...",
          "chainId": 1,
          "decimals": 18,
          "image": "https://example.com/image.png",
          "name": "Token Name",
          "symbol": "TKN",
          "cryptoBalance": 10,
          "fiatBalance": 100
        }
      ]
    }
  ]
}

The getPortfolios function returns an object containing an array of portfolios for the provided addresses. Each portfolio is an object with the address of the wallet, the fiat value of the portfolio, and an array of tokens held by the provided address.

Before using this endpoint, make sure to obtain a Client API Key from Coinbase Developer Platform.

Please note: getPortfolios is only available for Base mainnet and Ethereum mainnet. You can control the network in the OnchainKitProvider by setting the chain prop.

Returns

Promise<GetPortfoliosResponse>

Parameters

GetPortfoliosParams

Body

application/json

Response

200 - application/json

Successful response – Array of portfolio objects

The response is of type object.