Skip to main content

Autonomi client API

Project description

Autonomi Python Bindings

The Autonomi client library provides Python bindings for easy integration with Python applications.

Installation

We recommend using uv for Python environment management:

uv venv
uv pip install autonomi-client

Quick Start

from autonomi_client import Client, Wallet, PaymentOption

# Initialize wallet with private key
wallet = Wallet("your_private_key_here")
print(f"Wallet address: {wallet.address()}")
print(f"Balance: {wallet.balance()}")

# Connect to network
client = Client.connect(["/ip4/127.0.0.1/tcp/12000"])

# Create payment option
payment = PaymentOption.wallet(wallet)

# Upload data
data = b"Hello, Safe Network!"
addr = client.data_put_public(data, payment)
print(f"Data uploaded to: {addr}")

# Download data
retrieved = client.data_get_public(addr)
print(f"Retrieved: {retrieved.decode()}")

API Reference

Client

The main interface to interact with the Autonomi network.

Connection Methods

  • connect(peers: List[str]) -> Client
    • Connect to network nodes
    • peers: List of multiaddresses for initial network nodes

Data Operations

  • data_put_public(data: bytes, payment: PaymentOption) -> str

    • Upload public data to the network
    • Returns address where data is stored
  • data_get_public(addr: str) -> bytes

    • Download public data from the network
    • addr: Address returned from data_put_public
  • data_put(data: bytes, payment: PaymentOption) -> DataMapChunk

    • Store private (encrypted) data
    • Returns access information for later retrieval
  • data_get(access: DataMapChunk) -> bytes

    • Retrieve private data
    • access: DataMapChunk from previous data_put

Pointer Operations

  • pointer_get(address: str) -> Pointer

    • Retrieve pointer from network
    • address: Hex-encoded pointer address
  • pointer_put(pointer: Pointer, wallet: Wallet)

    • Store pointer on network
    • Requires payment via wallet
  • pointer_cost(key: VaultSecretKey) -> str

    • Calculate pointer storage cost
    • Returns cost in atto tokens

Vault Operations

  • vault_cost(key: VaultSecretKey) -> str

    • Calculate vault storage cost
  • write_bytes_to_vault(data: bytes, payment: PaymentOption, key: VaultSecretKey, content_type: int) -> str

    • Write data to vault
    • Returns vault address
  • fetch_and_decrypt_vault(key: VaultSecretKey) -> Tuple[bytes, int]

    • Retrieve vault data
    • Returns (data, content_type)
  • get_user_data_from_vault(key: VaultSecretKey) -> UserData

    • Get user data from vault
  • put_user_data_to_vault(key: VaultSecretKey, payment: PaymentOption, user_data: UserData) -> str

    • Store user data in vault
    • Returns vault address

Wallet

Ethereum wallet management for payments.

  • new(private_key: str) -> Wallet

    • Create wallet from private key
    • private_key: 64-char hex string without '0x' prefix
  • address() -> str

    • Get wallet's Ethereum address
  • balance() -> str

    • Get wallet's token balance
  • balance_of_gas() -> str

    • Get wallet's gas balance

PaymentOption

Configure payment methods.

  • wallet(wallet: Wallet) -> PaymentOption
    • Create payment option from wallet

Pointer

Handle network pointers for referencing data.

  • new(target: str) -> Pointer

    • Create new pointer
    • target: Hex-encoded target address
  • address() -> str

    • Get pointer's network address
  • target() -> str

    • Get pointer's target address

VaultSecretKey

Manage vault access keys.

  • new() -> VaultSecretKey

    • Generate new key
  • from_hex(hex: str) -> VaultSecretKey

    • Create from hex string
  • to_hex() -> str

    • Convert to hex string

UserData

Manage user data in vaults.

  • new() -> UserData

    • Create new user data
  • add_file_archive(archive: str) -> Optional[str]

    • Add file archive
    • Returns archive ID if successful
  • add_private_file_archive(archive: str) -> Optional[str]

    • Add private archive
    • Returns archive ID if successful
  • file_archives() -> List[Tuple[str, str]]

    • List archives as (id, address) pairs
  • private_file_archives() -> List[Tuple[str, str]]

    • List private archives as (id, address) pairs

DataMapChunk

Handle private data storage references.

  • from_hex(hex: str) -> DataMapChunk

    • Create from hex string
  • to_hex() -> str

    • Convert to hex string
  • address() -> str

    • Get short reference address

Utility Functions

  • encrypt(data: bytes) -> Tuple[bytes, List[bytes]]
    • Self-encrypt data
    • Returns (data_map, chunks)

Examples

See the examples/ directory for complete examples:

  • autonomi_example.py: Basic data operations
  • autonomi_pointers.py: Working with pointers
  • autonomi_vault.py: Vault operations
  • autonomi_private_data.py: Private data handling
  • autonomi_private_encryption.py: Data encryption
  • autonomi_advanced.py: Advanced usage scenarios

Best Practices

  1. Always handle wallet private keys securely
  2. Check operation costs before executing
  3. Use appropriate error handling
  4. Monitor wallet balance for payments
  5. Use appropriate content types for vault storage
  6. Consider using pointers for updatable references
  7. Properly manage and backup vault keys

For more examples and detailed usage, see the examples in the repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

autonomi_client-0.4.1-cp38-abi3-win_amd64.whl (8.6 MB view details)

Uploaded CPython 3.8+Windows x86-64

autonomi_client-0.4.1-cp38-abi3-musllinux_1_2_x86_64.whl (10.6 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ x86-64

autonomi_client-0.4.1-cp38-abi3-musllinux_1_2_armv7l.whl (10.1 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARMv7l

autonomi_client-0.4.1-cp38-abi3-musllinux_1_2_aarch64.whl (10.4 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

autonomi_client-0.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.4 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

autonomi_client-0.4.1-cp38-abi3-macosx_11_0_arm64.whl (9.1 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

autonomi_client-0.4.1-cp38-abi3-macosx_10_12_x86_64.whl (9.4 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file autonomi_client-0.4.1-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for autonomi_client-0.4.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5ca8a1acaf738f2765d67dd87c10a7282fbf6045956dc3c6f5637673da5f89af
MD5 8c93814bc77962de6a1d79c17b7f94e0
BLAKE2b-256 cb47b4126e5f104776e31f9e8f0a1acca07f42749a67d5932264401b520352d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for autonomi_client-0.4.1-cp38-abi3-win_amd64.whl:

Publisher: python-publish-client.yml on dirvine/autonomi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file autonomi_client-0.4.1-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for autonomi_client-0.4.1-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b308718780ebb984d29d02098ed147ad4767e053322c5c518e584096623145f2
MD5 0a15b8c75169e8757a2fe01fea8fe1ce
BLAKE2b-256 7385acd89ba4952662ee84abc3576bccb5eb4015d2ce7165bc1b44efb1477802

See more details on using hashes here.

Provenance

The following attestation bundles were made for autonomi_client-0.4.1-cp38-abi3-musllinux_1_2_x86_64.whl:

Publisher: python-publish-client.yml on dirvine/autonomi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file autonomi_client-0.4.1-cp38-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for autonomi_client-0.4.1-cp38-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 51e116cf99b7949927da12c6b6d3d94876c7963a0403e068921dd597ff909050
MD5 9d3b8ba06f60bcf53e0b3d1687b7ffb8
BLAKE2b-256 31db6adaabffa3d8ccb344862585d769167ceaaa4841fad8fdab2b0da3e6a001

See more details on using hashes here.

Provenance

The following attestation bundles were made for autonomi_client-0.4.1-cp38-abi3-musllinux_1_2_armv7l.whl:

Publisher: python-publish-client.yml on dirvine/autonomi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file autonomi_client-0.4.1-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for autonomi_client-0.4.1-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 b98ba98445a952c42a98dacddadb0a58ac0e91c8a9caf4660ebcf36c7a87a655
MD5 b50fc109f09de0625ac581c83df1f77b
BLAKE2b-256 eef18eecb400cd7412389ef7080cd7132b84bcdaf14b38f2c3ca823f2d08d63d

See more details on using hashes here.

Provenance

The following attestation bundles were made for autonomi_client-0.4.1-cp38-abi3-musllinux_1_2_aarch64.whl:

Publisher: python-publish-client.yml on dirvine/autonomi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file autonomi_client-0.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for autonomi_client-0.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8933d016276c60064911e5e1dad74e2a8658f6a8608ec3c30c7f050cfb2d6be8
MD5 3c056d7bbc56f6e6f71f519c53b13578
BLAKE2b-256 ffef8e95df0630ee618c3c120288c86ce25a254822eeac5dae5d7e92eb609591

See more details on using hashes here.

Provenance

The following attestation bundles were made for autonomi_client-0.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish-client.yml on dirvine/autonomi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file autonomi_client-0.4.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for autonomi_client-0.4.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3398d3a32c05c43a621694b76858b50981d7e52db16ad6ae72aa79ebac03e939
MD5 2b32078e8a926efa165f2f7685fbd06f
BLAKE2b-256 54af478b36332826ead0a103809112b01dd30442bf5ad9d18e70e7fff0f00822

See more details on using hashes here.

Provenance

The following attestation bundles were made for autonomi_client-0.4.1-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: python-publish-client.yml on dirvine/autonomi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file autonomi_client-0.4.1-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for autonomi_client-0.4.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0aca0b9bb5518a07178378c993aa97f7f64fcbc7a256f2e659b155e7d0b0fb06
MD5 a7d40570ee2e210a1d298adac3b854cd
BLAKE2b-256 0b21aaab2f856cb6978f45980a2296356fb0ed5ccdd81433eb126b8aa791eaba

See more details on using hashes here.

Provenance

The following attestation bundles were made for autonomi_client-0.4.1-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: python-publish-client.yml on dirvine/autonomi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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