LogoLogo
HomeMetadata APIAPI PROTwitter
Etherscan V2
Etherscan V2
  • Introduction
  • Chef's Pick
  • Rate Limits
  • V1 to V2 API Migration Guide
  • ✨Getting Started
    • Creating an Account
    • Getting an API Key
    • Supported Chains
    • Supported Endpoints
  • 🎯API Endpoints
    • Nametags
    • Accounts
    • Contracts
    • Transactions
    • Blocks
    • Logs
    • Geth/Parity Proxy
    • Tokens
    • Gas Tracker
    • Stats
    • L2 Deposits/Withdrawals
    • Usage
  • 🏆API PRO
    • Etherscan API PRO
    • Metadata/Name Tag API
  • 🍳Cookbook
    • Track Uniswap V4 DEX Trades
  • Get An Address's Full Transaction History
  • 🤝Support
    • FAQ
    • Legacy V1 Docs
    • Checking Usage
    • Common Error Messages
    • Getting Help
  • Visit Etherscan.io
Powered by GitBook
On this page
  • If you're coming from V1
  • If you're coming from another explorer, Basescan/Arbiscan/Polygonscan etc
  • If you're starting with V2

V1 to V2 API Migration Guide

If you're coming from V1

Your base url looks like this

https://api.etherscan.io/api

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

https://api.etherscan.io/v2/api?chainid=1

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

Your query looks something like one of these

https://api.basescan.org/api
https://api.polygonscan.com/api
https://api.bscscan.com/api
https://api.apescan.io/api

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

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()

PreviousRate LimitsNextCreating an Account

Last updated 6 months ago