Skip to content
A Python library for the Steem Blockchain
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
nozzle
.gitignore
LICENSE
README.md
setup.py

README.md

nozzle

A minimal Python library for the Steem Blockchain.

Requirements

Nozzle requires Python >= 3.5

Dependencies

Nozzle depends on the following external packages:

  • urllib3
  • certifi

Installation

pip install --upgrade pip setuptools
pip install steem-nozzle

Usage

from nozzle import Steem

steem = Steem(nodes=[
    'https://api.steemit.com',
    'https://steemd.minnowsupportproject.org',
    'https://steemd.privex.io',
    'https://steemd.pevo.science',
    'https://rpc.steemliberator.com',
    'https://gtg.steem.house:8090',
])

print(steem.dynamic_global_properties)
print(steem.call('get_accounts', ['blockbrothers']))

nozzle.Steem (nozzle.steemd.SteemdClient) is a subclass of nozzle.client.RPCClient with more high-level functions to interact with steemd (more to be added in the future).

Use RPCClient as a low-level interface to steemd. You can make API requests by utilizing the call() method on an instance:

print(client.call('get_accounts', ['blockbrothers']))

If you'd like fine-grained control over the retry configuration, pass an instance of urllib3.util.retry.Retry when creating an instance of RPCClient:

from urllib3.util.retry import Retry
from nozzle.client import DEFAULT_RETRY_OPTS
retries=Retry(**DEFAULT_RETRY_OPTS)

Please note that for correct failover behaviour, raise_on_redirect and raise_on_status need to be set to True. Also, POST is required to be in the method_whitelist. If you omit these or supply different values, it will be overridden by nozzle to ensure proper functioning.

For convenience, you can access the default Retry() settings from nozzle.client.DEFAULT_RETRY_OPTS:

METHOD_WHITELIST = Retry.DEFAULT_METHOD_WHITELIST.union({'POST'})
STATUS_FORCELIST = {408, 444, 499, 500, 502, 503, 504, 520, 521, 522, 523, 524, 527}

DEFAULT_RETRY_OPTS = {
    'connect': 5,
    'read': 0,
    'redirect': 5,
    'status': 3,
    'method_whitelist': METHOD_WHITELIST,
    'status_forcelist': STATUS_FORCELIST,
    'backoff_factor': 0.1,
    'raise_on_redirect': True,
    'raise_on_status': True
}

The timeouts can be controlled by providing an urllib3.util.timeout.Timeout instance:

from urllib3.util.timeout import Timeout
from nozzle.client import RPCClient

client = RPCClient(nodes=['https://api.steemit.com'], timeout=Timeout(connect=2.0, read=7.0))

Extend nozzle.client.RPCClient or nozzle.steemd.SteemdClient to support more operations.

You can’t perform that action at this time.