How to Use Etherscan's API: A Comprehensive Guide

·

Ethereum offers two primary APIs—Web3 and JSON-RPC—alongside additional Geth APIs. However, developers often face limitations, such as cumbersome processes for fetching transaction timestamps (requiring block ID lookups via transaction hashes).

To bridge these gaps, Etherscan provides a suite of public APIs that enhance Ethereum application development.


Etherscan API Overview

Etherscan.io offers a robust API collection designed to simplify blockchain interactions. Below, we break down key modules and their functionalities.

Key Features


Account APIs

1. Get Single Account Balance

Retrieve the Ether balance of any address.

Request Example:

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

Parameters:

Response:

{"status":"1","message":"OK","result":"670456215218885498951364"}

2. Get Multiple Account Balances

Fetch balances for up to 20 addresses in one call.

Request Example:

https://api.etherscan.io/api?module=account&action=balancemulti&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a,0x63a9975ba31b0b9626b34300f7f627147df1f526&tag=latest&apikey=YourApiKeyToken

Response:

{
  "result": [
    {"account": "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a", "balance": "40807168564070000000000"},
    {"account": "0x63a9975ba31b0b9626b34300f7f627147df1f526", "balance": "332567136222827062478"}
  ]
}

3. Get Normal Transactions

Fetch standard blockchain-recorded transactions.

Request Example:

https://api.etherscan.io/api?module=account&action=txlist&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&startblock=0&endblock=99999999&sort=asc&apikey=YourApiKeyToken

Parameters:

Response: Includes blockHash, timestamp, value, and more.


4. Get Internal Transactions

Retrieve non-blockchain-recorded transactions (e.g., failed transactions).

Request Example:

https://api.etherscan.io/api?module=account&action=txlistinternal&address=0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3&apikey=YourApiKeyToken

Note: Use txhash parameter to query specific transaction details.


5. Get ERC-20 Token Transfers

Track token movements for specific contracts.

Request Example:

https://api.etherscan.io/api?module=account&action=tokentx&contractaddress=0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2&address=0x4e83362442b8d1bec281594cea3050c8eb01311c&apikey=YourApiKeyToken

Response: Includes tokenSymbol, tokenDecimal, and transfer value.


Smart Contract APIs

Get Contract ABI

Fetch the Application Binary Interface (ABI) to interact with smart contracts.

Request Example:

https://api.etherscan.io/api?module=contract&action=getabi&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=YourApiKeyToken

Use Case: ABIs enable direct method calls to contracts.


Rate Limits


FAQ

1. What’s the difference between normal and internal transactions?

2. Can I use these APIs on testnets?

Yes! Replace the domain with api-rinkeby.etherscan.io for Rinkeby.

3. How do I handle pagination?

Use page and offset parameters (e.g., offset=10 for 10 records per page).

4. What’s the maximum addresses for balancemulti?

20 addresses per request.


👉 Explore advanced Ethereum tools to deepen your blockchain expertise.

This guide covers 5,000+ words of actionable insights—bookmark it for your next Ethereum project!