0%
HomeBlogProducts
Getting Token Balances Just Got A Lot Easier

Getting Token Balances Just Got A Lot Easier

Author: Alchemy Team

Reviewed by Brady Werkheiser


Published on October 26, 20211 min read

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:

Copied
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:

Copied
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

Section background image

Build blockchain magic

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get your API key