Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pcko1/bscscan-python

The most popular asynchronous Python API for BscScan (Binance Smart Chain Explorer), available via PyPI.
https://github.com/pcko1/bscscan-python

asyncio binance binance-smart-chain blockchain blockchain-explorer bsc python

Last synced: 3 months ago
JSON representation

The most popular asynchronous Python API for BscScan (Binance Smart Chain Explorer), available via PyPI.

Awesome Lists containing this project

README

        

# 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)

* `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`
* `get_bep721_token_transfer_events_by_contract_address_paginated`
* `get_bep721_token_transfer_events_by_address_and_contract_paginated`
* `get_validated_blocks_by_address`
* `get_validated_blocks_by_address_paginated`

Contracts (source)



* `get_contract_abi`
* `get_contract_source_code`

Transactions (source)



* `get_tx_receipt_status`

Blocks (source)



* `get_block_reward_by_block_number`
* `get_est_block_countdown_time_by_block_number`
* `get_block_number_by_timestamp`

GETH/Parity Proxy (source)

* `get_proxy_block_number`
* `get_proxy_block_by_number`
* `get_proxy_block_transaction_count_by_number`
* `get_proxy_transaction_by_hash`
* `get_proxy_transaction_by_block_number_and_index`
* `get_proxy_transaction_count`
* `get_proxy_transaction_receipt`
* `get_proxy_call`
* `get_proxy_code_at`
* `get_proxy_storage_position_at`
* `get_proxy_gas_price`
* `get_proxy_est_gas`

Tokens (source)



* `get_total_supply_by_contract_address`
* `get_circulating_supply_by_contract_address`
* `get_acc_balance_by_token_contract_address`

Stats (source)



* `get_total_bnb_supply`
* `get_validators_list`

Logs (source)



* `get_logs`

*If you think that a newly-added method is missing, kindly open an [issue](https://github.com/pcko1/bscscan-python/issues) as a feature request and I will do my best to add it.*

## Installation

Before proceeding, you should register an account on [BscScan.com](https://bscscan.com/) and [generate a personal API key](https://bscscan.com/myapikey) to use.

Install from source:

``` bash
pip install git+https://github.com/pcko1/bscscan-python.git@stable
```

Alternatively, install from [PyPI](https://pypi.org/project/bscscan-python/):

```bash
pip install bscscan-python
```

## Unit tests

In `bash`, test that everything looks OK on your end using your `YOUR_API_KEY` (without quotation marks):

``` bash
bash 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](https://bscscan.com/) API key:

``` python
import 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](https://bscscan-python.pankotsias.com/bscscan.modules.html). [![Documentation Status](https://img.shields.io/badge/docs-passing-brightgreen)](https://bscscan-python.pankotsias.com/)

## Issues

For problems regarding installing or using the package please open an [issue](https://github.com/pcko1/bscscan-python/issues). 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](https://bscscan.com/apis).