V2 Quickstart

If you're coming from V1

Your query looks something like this

https://api.etherscan.io/api?module=account&action=balance&address=0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae&tag=latest&apikey=YourApiKeyToken

Just append V2 to the base url, and a chainId parameter

https://api.etherscan.io/v2/api?chainid=1&module=account&action=balance&address=0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae&tag=latest&apikey=YourApiKeyToken

The endpoint accepts one chainId at a time, so repeat this for all the chains you want to query

If you're coming from another explorer, Basescan/Arbiscan/Polygonscan etc

Your query looks something like this

https://api.basescan.org/api?module=account&action=balance&address=0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae&tag=latest&apikey=YourApiKeyToken

Change your base URL to Etherscan, and point the chainId to 8453 or any chain you want

https://api.etherscan.io/v2/api?chainid=8453&module=account&action=balance&address=0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae&tag=latest&apikey=YourApiKeyToken

If you're starting with V2

Run this complete script with Node JS, node script.js

async function main() {

    // query ETH balances on Arbitrum, Base and Optimism

    const chains = [42161, 8453, 10]

    for (const chain of chains) {

        // endpoint accepts one chain at a time, loop for all your chains
   
        const query = await fetch(`https://api.etherscan.io/v2/api
           ?chainid=${chain}
           &module=account
           &action=balance
           &address=0xb5d85cbf7cb3ee0d56b3bb207d5fc4b82f43f511
           &tag=latest&apikey=YourApiKeyToken`)
           
        const response = await query.json()

        const balance = response.result
        console.log(balance)

    }
}

main()

Last updated