Skip to main content

A Python API wrapper for the Atto node API.

Project description

ReadTheDocs Project generated with PyScaffold

atto.py

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:4]}...\\t{entry.amount}')

Example output:

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

Installation

Simply run pip install atto.py.

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.

Need help?

I’m always available in the Atto Discord server. Feel free to get in touch.

For some insight into what inspired me to write this library, see this blog post.

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.3.tar.gz (34.2 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.3-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: atto_py-0.1.3.tar.gz
  • Upload date:
  • Size: 34.2 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.3.tar.gz
Algorithm Hash digest
SHA256 b12747a8aa7fb495a5cbc10c90c50993b9ec70305b96901cb343a1bfb6ee0784
MD5 a4d4f21c997d15f1ab595fcb69d39eba
BLAKE2b-256 b224b93b5ba6d8015a0757d8624f574242ee782f42e981fc4267bd20973f11e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: atto_py-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 23.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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 83de3949e1761ff8cc93beff361f8f1350fcae884d4d17503a788ccf80a3fbce
MD5 ae507840f87923da89eb9bb6f5554850
BLAKE2b-256 9efc080e7b126442c727c1a9722101526121bd892a8c56e48864aab63a2d973a

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