pcko1
etherscan-python
Python

A minimal, yet complete, python API for Etherscan.io.

Last updated Jul 9, 2026
421
Stars
115
Forks
13
Issues
0
Stars/day
Attention Score
94
Language breakdown
Python 99.8%
Shell 0.2%
Files click to expand
README

etherscan-python

Build Status codecov Codacy Badge Maintainability CodeFactor

PyPI PyPI - Downloads GitHub Python 3.8 DOI

A minimal, yet complete, Python API for Etherscan.io.

All standard and pro endpoints are provided. Kovan, Rinkeby and Ropsten testnets are also supported.

Available on PyPI. Powered by Etherscan.io APIs.


Endpoints

The following endpoints are provided:

Accounts (source)

  • getethbalance
  • getethbalance_multiple
  • getnormaltxsbyaddress
  • getnormaltxsbyaddress_paginated
  • getinternaltxsbyaddress
  • getinternaltxsbyaddress_paginated
  • getinternaltxsbytxhash
  • getinternaltxsbyblockrangepaginated
  • geterc20tokentransfereventsbyaddress
  • geterc20tokentransfereventsbycontractaddresspaginated
  • geterc20tokentransfereventsbyaddressandcontract_paginated
  • geterc721tokentransfereventsbyaddress
  • geterc721tokentransfereventsbycontractaddresspaginated
  • geterc721tokentransfereventsbyaddressandcontract_paginated
  • getminedblocksbyaddress
  • getminedblocksbyaddress_paginated

Contracts (source)

  • getcontractabi
  • getcontractsource_code

Transactions (source)

  • getcontractexecution_status
  • gettxreceipt_status

Blocks (source)

  • getblockrewardbyblock_number
  • getestblockcountdowntimebyblock_number
  • getblocknumberbytimestamp

GETH/Parity Proxy (source)

  • getproxyblock_number
  • getproxyblockbynumber
  • getproxyunclebyblocknumberand_index
  • getproxyblocktransactioncountbynumber
  • getproxytransactionbyhash
  • getproxytransactionbyblocknumberand_index
  • getproxytransaction_count
  • getproxytransaction_receipt
  • getproxycall
  • getproxycode_at
  • getproxystoragepositionat
  • getproxygas_price
  • getproxyest_gas

Tokens (source)

  • gettotalsupplybycontract_address
  • getaccbalancebytokenandcontract_address

Gas Tracker (source)

  • getestconfirmation_time
  • getgasoracle

Stats (source)

  • gettotaleth_supply
  • getethlast_price
  • getethnodes_size

Pro (PRO API key needed) (source)

  • gethistethbalanceforaddressbyblockno
  • getdailyaverageblocksize
  • getdailyblockcountand_rewards
  • getdailyblock_rewards
  • getdailyaverageblocktime
  • getdailyuncleblockcountandrewards
  • gethisterc20tokentotalsupplybycontractaddressandblock_no
  • gethisterc20tokenaccountbalancefortokencontractaddressbyblockno
  • gettokeninfobycontract_address
  • getdailyaveragegaslimit
  • getethdailytotalgas_used
  • getethdailyaveragegas_price
  • getethdailynetworktx_fee
  • getdailynewaddresscount
  • getdailynetwork_utilization
  • getdailyaveragenetworkhash_rate
  • getdailytx_count
  • getdailyaveragenetworkdifficulty
  • getethhistdailymarket_cap
  • getethhist_price

If you think that a newly-added method is missing, kindly open an issue as a feature request and I will do my best to add it.

Installation

Before proceeding, you should register an account on Etherscan.io and generate a personal API key to use.

If you wish to have access to the PRO endpoints, you should obtain elevated privileges via Etherscan's subscription service.

Install from source:

bash
pip install git+https://github.com/pcko1/etherscan-python.git

Alternatively, install from PyPI:

pip install etherscan-python

Unit tests

In bash, test that everything looks OK on your end using your YOURAPIKEY (without quotation marks) before proceeding:

bash
bash runtests.sh YOURAPI_KEY

This will regenerate the logs under logs/ with the most recent results and the timestamp of the execution.

The tests also include the PRO endpoints so if your key is not PRO, the correspondings tests are expected to fail.

Usage

In python, create a client with your personal Etherscan.io API key:

<pre><code class="lang-">python from etherscan import Etherscan eth = Etherscan(YOURAPIKEY) # key in quotation marks</code></pre>

Then you can call all available methods, e.g.:

<pre><code class="lang-">python eth.getethbalance(address=&quot;0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&quot;)

&gt; &#39;40891631566070000000000&#39;</code></pre> You can also choose one of the other testnets: <pre><code class="lang-">python eth = Etherscan(YOURAPIKEY, net=&quot;ropsten&quot;) # net name is case-insensitive, default is main</code></pre>

Examples

Examples (arguments and results) for all methods may be found as JSON files here. For example, if you want to use the method getblocknumberbytimestamp, you can find the supported arguments and the format of its output in its respective JSON file:

<pre><code class="lang-">json { &quot;method&quot;: &quot;getblocknumberbytimestamp&quot;, &quot;module&quot;: &quot;blocks&quot;, &quot;kwargs&quot;: { &quot;timestamp&quot;: &quot;1578638524&quot;, &quot;closest&quot;: &quot;before&quot; }, &quot;log_timestamp&quot;: &quot;2020-10-28-12:34:44&quot;, &quot;res&quot;: &quot;9251482&quot; }</code></pre>

where kwargs refer to the required named arguments and res` refers to the expected result if you were to run:

python
eth.getblocknumberbytimestamp(timestamp="1578638524", closest="before")

> '9251482'

Disclaimer: Those examples blindly use the arguments originally showcased here and the selected wallets/contracts do not reflect any personal preference. You should refer to the same source for additional information regarding specific argument values.

Issues

For problems regarding installing or using the package please open an issue. Kindly avoid disclosing potentially sensitive information such as your API keys or your wallet addresses.

Cite

Kotsias, P. C., pcko1/etherscan-python. https://github.com/pcko1/etherscan-python (2020). doi:10.5281/zenodo.4306855

or in

:

@misc{Kotsias2020,
  author = {Kotsias, P.C.},
  title = {pcko1/etherscan-python},
  year = {2020},
  publisher = {Zenodo},
  url = {https://github.com/pcko1/etherscan-python},
  doi = {10.5281/zenodo.4306855}
}

Feel free to leave a :star: if you found this package useful.


Powered by Etherscan.io APIs.

© 2026 GitRepoTrend · pcko1/etherscan-python · Updated daily from GitHub