Skip to main content

An unofficial wrapper for the Etherscan.io API

Project description

https://travis-ci.org/Marto32/pyetherscan.svg?branch=master https://coveralls.io/repos/github/Marto32/pyetherscan/badge.svg?branch=master https://img.shields.io/pypi/pyversions/pyetherscan.svg https://img.shields.io/pypi/v/pyetherscan.svg

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.

Join the chat at https://gitter.im/pyetherscan/Lobby

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

pyetherscan-0.1.2.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

pyetherscan-0.1.2-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file pyetherscan-0.1.2.tar.gz.

File metadata

  • Download URL: pyetherscan-0.1.2.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyetherscan-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f281c125b2ee86ed93853aa00e64ab2b25b77a8ae325353bc27e2b41bcd892c7
MD5 7eb3fe8ca18f35f0147355515650efbb
BLAKE2b-256 a5f5798ccf10818ae25b11e50f641785a18f5379aaeaffed436f73dcbf9254c6

See more details on using hashes here.

File details

Details for the file pyetherscan-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pyetherscan-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f19063900ff4630974dc1e9646872def27e1638770251ca492513696d14f65f
MD5 14abc83bce1466c72ec3de39c30f2534
BLAKE2b-256 14d71f2d5ecbe759af5eec8f2a4938f39b969f8adfe28def117c7bd0eb61f372

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page