An unofficial wrapper for the Etherscan.io API
Project description
pyetherscan
An unofficial wrapper for the Etherscan API.
Installation
We recommend you install this library in a new virtual environment.
To install, create a new etherscan account and make note of your API key. Then install the library by running:
pip install pyetherscan
After installation, there are two main ways to set your API key. The first is by creating a configuration file named .pyetherscan.ini and saving it in your home directory. The format for this file is as follows:
[Credentials]
ETHERSCAN_API_KEY: YourApiKeyToken
The second is by setting the environment variable ETHERSCAN_API_KEY.
If you do not use either option, the package will connect to the ropsten test chain via the Etherscan API by default.
Usage
There are two main ways to use the library. The first is via the Client object to interact directly with the Etherscan API.
In [1]: from pyetherscan import Client
In [2]: client = Client()
In [3]: address = '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae'
In [4]: address_balance = client.get_single_balance(address)
In [5]: address_balance.response_status_code
Out[5]: 200
In [6]: address_balance.message
Out[6]: 'OK'
In [7]: address_balance.balance
Out[7]: 748997604382925139479303
The second is to use pyetherscan objects which fully abstract the API. These objects can be found in the pyetherscan.ethereum module and include:
Transaction
Address
Block
Token
For example:
In [1]: from pyetherscan import Address
In [2]: address = '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae'
In [3]: ethereum_address = Address(address)
In [4]: ethereum_address.balance
Out[4]: 748997604382925139479303.0
In [4]: for txn in ethereum_address.transactions:
...: print(txn.value)
Contributing
Fork this repository, create a branch and issue a PR.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyetherscan-0.1.1.tar.gz
.
File metadata
- Download URL: pyetherscan-0.1.1.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee1e3610792f5ea59e7860b8f29d2e12ec480d452025eb3bd455959230d1aaa6 |
|
MD5 | 287de3445a710370ccd8f4f412adfb77 |
|
BLAKE2b-256 | f035c8fab3cb32476f285aaf24b57178964a347c9da4f992367fb5fdc214c248 |
File details
Details for the file pyetherscan-0.1.1-py2-none-any.whl
.
File metadata
- Download URL: pyetherscan-0.1.1-py2-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41233b4f1c2002770f78210b1d5a064f2fa57bf1f1e5ff655800276d34b7703b |
|
MD5 | 8a7ba25f6774461b4f13418a3eaad47d |
|
BLAKE2b-256 | c6d2580c2bf68386dc739ac97167d46d7b12e3fd8e2ba120466b586917bd087a |