Getting Token Balances Just Got A Lot Easier
The Enhanced API method alchemy_getTokenBalances has long been the best way for developers to get access to the balances of a list of tokens in a given wallet.
However, until now, this method required users to provide us with an explicit list of all token addresses they were interested in querying. Some developers found this laborious, so we’ve introduced a new option: developers can now simply call ‘alchemy_getTokenBalances’ with the value ‘DEFAULT_TOKENS’ to see the balances of the top 100 tokens by 24 hour volume.
So this:
curl https://eth-mainnet.alchemyapi.io/v2/your-api-key \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"alchemy_getTokenBalances","params": ["0xYourWalletAddress", [0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 0xf5d669627376ebd411e34b98f19c868c8aba5ada, 0x3506424f91fd33084466f402d5d97f05f8e3b4af, 0x0f5d2fb29fb7d3cfee444a200298f468908cc942, 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984, ...etc 95 more times]
],"id":"42"}'
Just became this:
curl https://eth-mainnet.alchemyapi.io/v2/your-api-key \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"alchemy_getTokenBalances","params": ["0xYourWalletAddress", "DEFAULT_TOKENS"],"id":"42"}'
Try it out in the composer!
And the best part, you can get started right away by making an Alchemy account free.
Related articles
Introducing Prices API
Save development time with our new API for real-time and historical token prices.
New Integrations for Rollups partner: Parsec
Say goodbye to confusing block explorers. Parsec brings context and visual transaction flows to your rolllups.
Deeper application insights at lower costs
By re-architecting back end infrastructure, Alchemy has passed up to 3x efficiency savings to you for four key debug_trace methods.