Code Monkey home page Code Monkey logo

bscscan-python's Introduction

bscscan-python

Build Status codecov Codacy Badge Maintainability CodeFactor

PyPI PyPI - Downloads GitHub Python 3.8 DOI

A complete Python API for BscScan.com, available on PyPI. Powered by BscScan.com APIs.

This is a gently modified 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_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

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:

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

Alternatively, install from PyPI:

pip install bscscan-python

Unit tests

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

bash run_tests.sh YOUR_API_KEY

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

Usage

In python, create a client with your personal BscScan.com API key:

from bscscan import BscScan
bsc = BscScan(YOUR_API_KEY) # key in quotation marks

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

bsc.get_bnb_balance(address="0x0000000000000000000000000000000000001004")

> '167195709084498025431541166'

Examples

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

{
  "method": "get_circulating_supply_by_contract_address",
  "module": "tokens",
  "kwargs": {
    "contract_address": "0xe9e7cea3dedca5984780bafc599bd69add087d56"
  },
  "log_timestamp": "2021-02-19-12:34:14",
  "res": "422504134592569820000000000"
}

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

bsc.get_circulating_supply_by_contract_address(contract_address="0xe9e7cea3dedca5984780bafc599bd69add087d56")

> '422504134592569820000000000'

Disclaimer: Those examples blindly use argument values (addresses, contracts, etc.) that were randomly chosen and do not reflect any personal preference.

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.4580473

or in 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.4580473}
}

Feel free to leave a โญ if you found this package useful.


Powered by Bscscan.com APIs.

bscscan-python's People

Contributors

codacy-badger avatar deepsource-autofix[bot] avatar deepsourcebot avatar pcko1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.