The most popular asynchronous Python API for BscScan (Binance Smart Chain Explorer), available via PyPI.
bscscan-python
A complete Python API for BscScan.com
Powered by BscScan.com APIs
Available on PyPI
:book: Read the official documentation here :book:
👇
A fork of the etherscan-python package.
Endpoints
The following endpoints are provided:
Accounts (source)
getbnbbalancegetbnbbalance_multiplegetnormaltxsbyaddressgetnormaltxsbyaddress_paginatedgetinternaltxsbyaddressgetinternaltxsbyaddress_paginatedgetinternaltxsbytxhashgetinternaltxsbyblockrangepaginatedgetbep20tokentransfereventsbyaddressgetbep20tokentransfereventsbycontractaddresspaginatedgetbep20tokentransfereventsbyaddressandcontract_paginatedgetbep721tokentransfereventsbyaddressgetbep721tokentransfereventsbycontractaddresspaginatedgetbep721tokentransfereventsbyaddressandcontract_paginatedgetvalidatedblocksbyaddressgetvalidatedblocksbyaddress_paginated
Blocks (source)
getblockrewardbyblock_numbergetestblockcountdowntimebyblock_numbergetblocknumberbytimestamp
GETH/Parity Proxy (source)
getproxyblock_numbergetproxyblockbynumbergetproxyblocktransactioncountbynumbergetproxytransactionbyhashgetproxytransactionbyblocknumberand_indexgetproxytransaction_countgetproxytransaction_receiptgetproxycallgetproxycode_atgetproxystoragepositionatgetproxygas_pricegetproxyest_gas
Tokens (source)
gettotalsupplybycontract_addressgetcirculatingsupplybycontract_addressgetaccbalancebytokencontractaddress
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:
bash
pip install git+https://github.com/pcko1/bscscan-python.git@stable
Alternatively, install from PyPI:
pip install bscscan-python
Unit tests
In bash, test that everything looks OK on your end using your YOURAPIKEY (without quotation marks):
bash
bash runtests.sh YOURAPI_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:
python
import asyncio
from bscscan import BscScan
YOURAPIKEY = "..."
async def main(): async with BscScan(YOURAPIKEY) as bsc: print(await bsc.getbnbbalance(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
:
@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.