Skip to content

Inspect Wallet Portfolio

Use client.portfolio for wallet-level Portfolio API methods. Portfolio requests use Alchemy network names such as eth-mainnet.

Token Balances

from alchemy import Alchemy

async with Alchemy.new() as client:
  balances = await client.portfolio.token_balances({
    'addresses': [
      {
        'address': '0x1E6E8695FAb3Eb382534915eA8d7Cc1D1994B152',
        'networks': ['eth-mainnet'],
      }
    ],
    'includeNativeTokens': True,
    'includeErc20Tokens': True,
    'pageSize': 2,
  })
  print(balances['data']['tokens'])

NFT Holdings

from alchemy import Alchemy

async with Alchemy.new() as client:
  nfts = await client.portfolio.nfts({
    'addresses': [
      {
        'address': '0x1E6E8695FAb3Eb382534915eA8d7Cc1D1994B152',
        'networks': ['eth-mainnet'],
        'excludeFilters': ['SPAM'],
        'spamConfidenceLevel': 'VERY_HIGH',
      }
    ],
    'withMetadata': True,
    'pageSize': 2,
    'orderBy': 'transferTime',
    'sortOrder': 'asc',
  })
  print(nfts['data']['ownedNfts'])

Transaction History

from alchemy import Alchemy

async with Alchemy.new() as client:
  history = await client.portfolio.transactions.history({
    'addresses': [
      {
        'address': '0x1E6E8695FAb3Eb382534915eA8d7Cc1D1994B152',
        'networks': ['eth-mainnet'],
      }
    ],
    'limit': 2,
  })
  print(history['transactions'])