Integrate multiple blockchains into your application in seconds with web3data-py

Why Web3Data-py?

  • Multi-blockchain - The simplest & most comprehensive blockchain methods
  • Integrate In Minutes - Each method is made simple yet comprehensive to support your functionality needs
  • Full RPC, Websocket Support - The entire breadth of a blockchain node is supported with direct RPC access.

Getting Started

1. Get a Free API Key

If you don't have an API Key already, now is a great time get one.


2. Installation

Latest Stable Release

To install web3data-py, run this command in your terminal:

pip install web3data

This is the preferred method to install web3data-py, as it will always install the most recent stable release.

If you don’t have pip installed, this Python installation guide can guide you through the process.

From sources

The sources for web3data-py can be downloaded from the Github repo.

You can either clone the public repository:

git clone git://github.com/dmuhs/web3data-py

Or download the tarball:

curl -OJL https://github.com/dmuhs/web3data-py/tarball/master

Once you have a copy of the source, you can install it with:

python setup.py install


To use web3data-py in a project:

w3d = Web3Data("YOUR_API_KEY")

This will print the raw response, such as:

 'title': 'OK',
 'description': 'Successful request',
 'payload': {'balance': '5296672643815245964',
  'balanceIn': '3.0894905437937322715551e+22',
  'balanceOut': '3.0889608765293507469587e+22',
  'addressType': 'contract',
  'changeInPrice': None,
  'contractTypes': ['ERC721'],
  'decimals': '0',
  'name': 'CryptoKitties',
  'numHolders': '84753',
  'numTokens': '1860119',
  'numTransfers': '2723659',
  'symbol': 'CK',
  'totalSupply': '1860119.0000000000000000',
  'totalValueUSD': None,
  'unitValueUSD': None}}

Supported Chains and Handlers

Each endpoint of the Amberdata web3 API can be hit for a specified chain. web3data-py follows the paradigm set by web3data-js and allows easy switching between chains by providing them as client attributes. Each attribute implements a sub-handler for several kinds of data, such as address-, market-, or transaction-related information.

The methods for each chain are fixed, however some chains might raise an APIError if the data is unavailable. For example, token-related queries on Bitcoin will raise an exception, because Bitcoin does not allow for smart-contracts and token implementations on-chain.

In [1]: w3d.eth.token.supply_latest("0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2")
{'status': 200,
 'title': 'OK',
 'description': 'Successful request',
 'payload': {'decimals': '18',
  'circulatingSupply': '985776.2571660122663385',
  'totalBurned': '1014178.1439074671310546',
  'totalMinted': '1999953.40106534372698',
  'totalSupply': '985775.2571578765959254',
  'totalTransfers': '678572'}}

And on the other hand:

In [1]: w3d.btc.token.supply_latest("0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2")
APIError                                  Traceback (most recent call last)
<ipython-input-12-93158fe945ad> in <module>
----> 1 w3d.btc.token.supply_latest("0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2")

~/repos/web3data-py/web3data/handlers/token.py in supply_latest(self, address)
    115         :return: The API response parsed into a dict
    116         """
--> 117         self._check_chain_supported()
    118         return self._token_query(address, "supplies/latest", {})

~/repos/web3data-py/web3data/handlers/base.py in _check_chain_supported(self)
     34     def _check_chain_supported(self):
     35         if self.chain in self.LIMITED:
---> 36             raise APIError(f"This method is not supported for {self.chain}")
     38     @staticmethod

APIError: This method is not supported for Chains.BTC

This behaviour aims to notify the developer as early as possible about invalid code and business logic errors that need fixing right away.

Currently, Amberdata supports the following chains, which are implemented as client instance attributes:

  • w3d.bch
  • w3d.bsv
  • w3d.btc
  • w3d.eth
  • w3d.eth_rinkeby
  • w3d.ltc
  • w3d.zec

Each chain attribute implements the following sub-handlers for specific API queries:

  • address
  • block
  • contract
  • market
  • signature
  • token
  • transaction

Further information on the implementation details can be found in the package documentation.

Full Documentation Reference: