Bscscan python
The most popular asynchronous Python API for BscScan (Binance Smart Chain Explorer), available via PyPI.
* `get_bnb_balance` * `get_bnb_balance_multiple` * `get_normal_txs_by_address` * `get_normal_txs_by_address_paginated` * `get_internal_txs_by_address` * `get_internal_txs_by_address_paginated` * `get_internal_txs_by_txhash` * `get_internal_txs_by_block_range_paginated` * `get_bep20_token_transfer_events_by_address` * `get_bep20_token_transfer_events_by_contract_address_paginated` * `get_bep20_token_transfer_events_by_address_and_contract_paginated` * `get_bep721_token_transfer_events_by_address`... The project is written primarily in Python, distributed under the MIT License license, first published in 2021. Key topics include: asyncio, binance, binance-smart-chain, blockchain, blockchain-explorer.
bscscan-python
<p align="center"> <a href="https://github.com/pcko1/bscscan-python" alt="build"> <img src="https://github.com/pcko1/bscscan-python/workflows/build/badge.svg" /></a> <a href="https://codecov.io/gh/pcko1/bscscan-python" alt="codecov"> <img src="https://codecov.io/gh/pcko1/bscscan-python/branch/master/graph/badge.svg" /></a> <a href="https://app.codacy.com/gh/pcko1/bscscan-python?utm_source=github.com&utm_medium=referral&utm_content=pcko1/bscscan-python&utm_campaign=Badge_Grade" alt="code-quality"> <img src="https://api.codacy.com/project/badge/Grade/a39faec4c53e45cda03c92d216278c65" /></a> <a href="https://codeclimate.com/github/pcko1/bscscan-python" alt="tech-debt"> <img src="https://img.shields.io/codeclimate/tech-debt/pcko1/bscscan-python" /></a> <a href="https://codeclimate.com/github/pcko1/bscscan-python/maintainability" alt="maintainability"> <img src="https://api.codeclimate.com/v1/badges/b9fefb77fed228a664d2/maintainability" /></a> <a href="https://www.codefactor.io/repository/github/pcko1/bscscan-python" alt="code-factor"> <img src="https://www.codefactor.io/repository/github/pcko1/bscscan-python/badge" /></a> </p> <p align="center"> <a href="https://badge.fury.io/py/bscscan-python" alt="pypi"> <img src="https://badge.fury.io/py/bscscan-python.svg" /></a> <a href="" alt="pypi-downloads"> <img src="https://img.shields.io/pypi/dm/bscscan-python" /></a> <a href="" alt="license"> <img src="https://img.shields.io/github/license/pcko1/bscscan-python" /></a> <a href="https://www.python.org/downloads/release/python-385/" alt="python-version"> <img src="https://img.shields.io/badge/python-3.8-blue.svg" /></a> <a href="https://zenodo.org/badge/latestdoi/340319392" alt="DOI"> <img src="https://zenodo.org/badge/340319392.svg" /></a> </p> <p align="center"> A complete Python API for <a href="https://bscscan.com/">BscScan.com</a> </p> <p align="center"> Powered by <a href="https://bscscan.com/apis">BscScan.com APIs</a> </p> <p align="center"> Available on <a href="https://pypi.org/project/bscscan-python/">PyPI</a> </p> <p align="center"> :book: Read the official documentation here :book: </p> <p align="center"> 👇 </p> <p align="center"> <a href="https://bscscan-python.pankotsias.com/" alt="docs"> <img src="https://img.shields.io/badge/docs-passing-brightgreen" /></a> </p> <p align="center"> <i>A fork of the <a href="https://github.com/pcko1/etherscan-python">etherscan-python</a> package.</i> </p>Endpoints
The following endpoints are provided:
<details><summary>Accounts <a href="https://bscscan.com/apis#accounts">(source)</a></summary> <p>get_bnb_balanceget_bnb_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_bep20_token_transfer_events_by_addressget_bep20_token_transfer_events_by_contract_address_paginatedget_bep20_token_transfer_events_by_address_and_contract_paginatedget_bep721_token_transfer_events_by_addressget_bep721_token_transfer_events_by_contract_address_paginatedget_bep721_token_transfer_events_by_address_and_contract_paginatedget_validated_blocks_by_addressget_validated_blocks_by_address_paginated
get_contract_abiget_contract_source_code
get_tx_receipt_status
get_block_reward_by_block_numberget_est_block_countdown_time_by_block_numberget_block_number_by_timestamp
get_proxy_block_numberget_proxy_block_by_numberget_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
get_total_supply_by_contract_addressget_circulating_supply_by_contract_addressget_acc_balance_by_token_contract_address
get_total_bnb_supplyget_validators_list
get_logs
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 BscScan.com and generate a personal API key to use.
Install from source:
bashpip install git+https://github.com/pcko1/bscscan-python.git@stable
Alternatively, install from PyPI:
bashpip install bscscan-python
Unit tests
In bash, test that everything looks OK on your end using your YOUR_API_KEY (without quotation marks):
bashbash run_tests.sh YOUR_API_KEY
Note: This will install the coverage package in your activated python environment.
Usage
In python, create a client with your personal BscScan.com API key:
pythonimport asyncio from bscscan import BscScan YOUR_API_KEY = "..." async def main(): async with BscScan(YOUR_API_KEY) as bsc: print(await bsc.get_bnb_balance(address="0x0000000000000000000000000000000000001004")) if __name__ == "__main__": asyncio.run(main()) > '167195709084498025431541166'
Examples
Detailed examples (arguments and results) for all methods may be found in the official documentation.
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/bscscan-python: v1.0.0. https://github.com/pcko1/bscscan-python (2021). doi:10.5281/zenodo.4781726
or in bibtex:
bibtex@misc{Kotsias2020, author = {Kotsias, P.C.}, title = {pcko1/bscscan-python}, year = {2021}, publisher = {Zenodo}, url = {https://github.com/pcko1/bscscan-python}, doi = {10.5281/zenodo.4781726} }
Feel free to leave a :star: if you found this package useful.
Powered by Bscscan.com APIs.
Contributors
Showing top 7 contributors by commit count.
