Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork113
A minimal, yet complete, python API for Etherscan.io.
License
pcko1/etherscan-python
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A minimal, yet complete, python API forEtherscan.io. Available onPyPI.
All FREE and PRO endpoints are provided.
Powered byEtherscan.io APIs.
The following endpoints are provided:
Accounts(source)
get_eth_balanceget_eth_balance_multipleget_normal_txs_by_addressget_normal_txs_by_address_paginatedget_internal_txs_by_addressget_internal_txs_by_address_paginatedget_internal_txs_by_txhashget_internal_txs_by_block_range_paginatedget_erc20_token_transfer_events_by_addressget_erc20_token_transfer_events_by_contract_address_paginatedget_erc20_token_transfer_events_by_address_and_contract_paginatedget_erc721_token_transfer_events_by_addressget_erc721_token_transfer_events_by_contract_address_paginatedget_erc721_token_transfer_events_by_address_and_contract_paginatedget_mined_blocks_by_addressget_mined_blocks_by_address_paginated
Contracts(source)
get_contract_abiget_contract_source_code
Transactions(source)
get_contract_execution_statusget_tx_receipt_status
Blocks(source)
get_block_reward_by_block_numberget_est_block_countdown_time_by_block_numberget_block_number_by_timestamp
GETH/Parity Proxy(source)
get_proxy_block_numberget_proxy_block_by_numberget_proxy_uncle_by_block_number_and_indexget_proxy_block_transaction_count_by_numberget_proxy_transaction_by_hashget_proxy_transaction_by_block_number_and_indexget_proxy_transaction_countget_proxy_transaction_receiptget_proxy_callget_proxy_code_atget_proxy_storage_position_atget_proxy_gas_priceget_proxy_est_gas
Tokens(source)
get_total_supply_by_contract_addressget_acc_balance_by_token_and_contract_address
Gas Tracker(source)
get_est_confirmation_timeget_gas_oracle
Stats(source)
get_total_eth_supplyget_eth_last_priceget_eth_nodes_size
Pro (PRO API key needed)(source)
get_hist_eth_balance_for_address_by_block_noget_daily_average_block_sizeget_daily_block_count_and_rewardsget_daily_block_rewardsget_daily_average_block_timeget_daily_uncle_block_count_and_rewardsget_hist_erc20_token_total_supply_by_contract_address_and_block_noget_hist_erc20_token_account_balance_for_token_contract_address_by_block_noget_token_info_by_contract_addressget_daily_average_gas_limitget_eth_daily_total_gas_usedget_eth_daily_average_gas_priceget_eth_daily_network_tx_feeget_daily_new_address_countget_daily_network_utilizationget_daily_average_network_hash_rateget_daily_tx_countget_daily_average_network_difficultyget_eth_hist_daily_market_capget_eth_hist_price
If you think that a newly-added method is missing, kindly open anissue as a feature request and I will do my best to add it.
Before proceeding, you should register an account onEtherscan.io andgenerate 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.
Assumingconda is already installed on your system, first create the environment:
conda env create -f env.yml
Activate the environment:
conda activate etherscan-python
Then, install the package:
pip install.Alternatively, you can install it fromPyPI:
pip install etherscan-python
Inbash, test that everything looks OK on your end using yourYOUR_API_KEY (without quotation marks) before proceeding:
bash run_tests.sh YOUR_API_KEY
This will regenerate the logs underlogs/ with the most recent results and the timestamp of the execution.
Inpython, create a client with your personalEtherscan.io API key:
frometherscanimportEtherscanapi_key=YOUR_API_KEY# use quotation marks because it is a Python stringconfig_path="configs/stable.json"eth=Etherscan.from_config(config_path,api_key)
Then you can call all available methods, e.g.:
eth.get_eth_balance(address="0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a")>'40891631566070000000000'
Examples (arguments and results) for all methods may be found as JSON fileshere. For example, if you want to use the methodget_block_number_by_timestamp, you can find the supported arguments and the format of its output in its respectiveJSON file:
{"method":"get_block_number_by_timestamp","module":"blocks","kwargs": {"timestamp":"1578638524","closest":"before" },"log_timestamp":"2020-10-28-12:34:44","res":"9251482"}wherekwargs refer to the required named arguments andres refers to the expected result if you were to run:
eth.get_block_number_by_timestamp(timestamp="1578638524",closest="before")>'9251482'
Disclaimer: Those examples blindly use the arguments originally showcasedhere 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.
For problems regarding installing or using the package please open anissue. Kindly avoid disclosing potentially sensitive information such as your API keys or your wallet addresses.
Kotsias, P. C., A Python API for Etherscan.io.https://github.com/pcko1/etherscan-python (2020). doi:10.5281/zenodo.4088586
or inbibtex:
@misc{Kotsias2020,author ={Kotsias, P.C.},title ={A Python API for Etherscan.io},year ={2020},publisher ={GitHub},journal ={GitHub repository},url ={https://github.com/pcko1/etherscan-python},doi ={10.5281/zenodo.4088586}}
Feel free to leave a ⭐ if you found this package useful.
Powered byEtherscan.io APIs.
About
A minimal, yet complete, python API for Etherscan.io.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Contributors3
Uh oh!
There was an error while loading.Please reload this page.