Skip to main content

A Python API wrapper for the Atto node API.

Project description

ReadTheDocs Project generated with PyScaffold

attopy

A Python API wrapper for the Atto node API.

An instance of AttoClient() represents a connection to an Atto node. Communication with the node happens through AttoClient()’s members.

The methods wrap the information from API responses in the form of Python builtins and classes in this module, such as:

  • Account

  • Entry

  • Receivable

  • Transaction

  • Block

Typical usage example:

from attopy import AttoClient, address_to_key

ADDRESS = '<your_address>'.removeprefix('atto://')

with AttoClient() as node:
    public_key = address_to_key(ADDRESS)
    account = node.get_account(public_key)
    print(f'balance: {account.balance}')

    # print first 100 transactions
    print('Hash\\tAmount')
    for entry in node.entries_stream(account, from_height=1, to_height=10, timeout=None):
        print(f'{entry.hash_[0:3]}...\\t{entry.amount}')

Example output:

balance: 1349500000
hash        Amount
A5DF...     10000000
BEEF...     49000000000
DEAD...     2500000000
... 97 more lines ...

What’s missing?

AttoClient() is a synchronous client, meaning that all calls are blocking. Generators that access endpoints that stream indefinitely (such as the endpoint to scan for new entries) therefore should not be iterated over using for without a timeout, as they will never end and cannot be interrupted without user intervention.

An asynchronous client, AttoClientAsync(), is in the works. This client would facilitate near-instant updating of UI elements representing balances and lists of new entries, and would be able to wait for transactions to be confirmed, all without blocking the main thread.

Currently, AttoClient() supports some of the GET methods provided by the node API, and none of the POST methods. This means that AttoClient() can only query nodes, and can’t post transactions. This will change once a testing framework has been set up.

All classes and members should be fully documented soon.

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

atto_py-0.1.0.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

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

atto_py-0.1.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file atto_py-0.1.0.tar.gz.

File metadata

  • Download URL: atto_py-0.1.0.tar.gz
  • Upload date:
  • Size: 33.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for atto_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 24b66ed3d6976a8693746d76650370a248ee1ccc0e6ae6a64561f38736d009a6
MD5 7c225b3a7cd6e203cfbe8e2afa5e16a8
BLAKE2b-256 79d66266f78a8c6c2ecab56dc97cfe6cef7fc25c2ce26d61316c3269ae144707

See more details on using hashes here.

File details

Details for the file atto_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: atto_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for atto_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e60ddd791e79ae00db1c55f1c696816cb6a863879ac5b74b4764e846095b036
MD5 14c273e7bf281b53004e3832ca01624b
BLAKE2b-256 bcdbad799c6ecf4b565b27ad19d05fbe9f15d3588db6999eef10c56f9f8d8076

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