Skip to main content

Python wrapper for Helium API to simplify interactions with the Helium blockchain.

Project description

hntpy

Introduction

hntpy is a Python wrapper for Helium API to simplify requests and interaction with Helium blockchain. The aim of this project is to enable retrieval of Helium data from the API in a Pythonic way.

For comprehensive documentation (with examples), review the full usage docs.

For more detail on exact API responses/data, please see the officical Helium documentation.

This project is continually under development. If you notice a bug, or have a feature request, please submit a Github issue here.

Install

To use the latest version of this Python package, download from PyPi:

pip install hntpy

Example Usage

Below are a couple of examples to show how the hntpy package can be used. For comprehensive documentation, including all function definitions, argument examples, and more, view the full docs.

from hntpy import Account, Hotspot, Validator

# ===================================

## sample account functionality
account = Account(address="51-character-account-address")

# get validators and hotspots associated with an account
validators = account.validators()
hotspots = account.hotspots()

# get a generator of rewards, in a given time window, for an account (optionally can also return a list)
rewards_generator = account.rewards(min_time="2022-01-01", max_time="2022-06-01", gen=True)

for batch in rewards_generator:
    for reward in batch:
        # do some processing with the reward here...

# ===================================

## sample hotspot functionality

hotspot = Hotspot(address="51-character-hotspot-address")

# get roles (activity) for a hotspot, can optionally provide timeframe and response limit
roles = hotspot.roles(min_time="2022-01-01", limit=100)

# get the total reward sum for the hotspot, optionally in a given timeframe
rewards = hotspot.rewards(min_time="2022-01-01", max_time="2022-06-01")

# get hotspots that the given hotspot witnessed over the last 5 days
witnessed = hotspot.witnessed()

# ===================================

## sample validator functionality

validator = Validator(address="51-character-validator-address")

# get roles (activity) for a hotspot, can optionally provide timeframe and response limit
roles = validator.roles(limit=200)

Return types

The Helium API returns either JSON objects (loaded as dicts) of data, or lists of data. All of the functions in the hntpy package that make requests to the Helium API return either:

  • list
  • dict
  • GeneratorType

For requests that have the potential to return large amounts of data, there is the option to provide a gen=True argument to the method, which will yield the data in batches (rather than compile and return one single large list). By default, gen parameter is set to False for all methods.

To see available return types for specific methods, see method definitions in the respective module's documentation page.

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

hntpy-0.0.9.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hntpy-0.0.9-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file hntpy-0.0.9.tar.gz.

File metadata

  • Download URL: hntpy-0.0.9.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.8.9 Darwin/21.6.0

File hashes

Hashes for hntpy-0.0.9.tar.gz
Algorithm Hash digest
SHA256 ca294fc5ec8ee31ba919e85b2d5ef909f2540ac6934eff8ec77ab9416e8af343
MD5 3e1f41f341b9ca2a7c7e52ea57a6b2a2
BLAKE2b-256 6e97fdd94d341f014e5a1e6b5d8e3d59d20e60690f9fd9c8daa063ee098594b8

See more details on using hashes here.

File details

Details for the file hntpy-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: hntpy-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.8.9 Darwin/21.6.0

File hashes

Hashes for hntpy-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 44536a98bc64bdc9addb296bdc84c6e3d7763d21b75b0af7f456e0b76a24b49e
MD5 b9d316c4861307334f68c7488ebd3caf
BLAKE2b-256 a4b4b1072e74c9a2aa5ca853b76bffba90645f3d150b74b2643a0dbcac2fc12d

See more details on using hashes here.

Supported by

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