autonomi-client


Nameautonomi-client JSON
Version 0.3.61 PyPI version JSON
download
home_pagehttps://maidsafe.net
SummaryAutonomi client API
upload_time2025-02-12 17:51:17
maintainerNone
docs_urlNone
authorMaidSafe Developers <dev@maidsafe.net>
requires_python>=3.8
licenseGPL-3.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```bash
uv venv
uv pip install autonomi-client
```

## Quick Start

```python
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.


            

Raw data

            {
    "_id": null,
    "home_page": "https://maidsafe.net",
    "name": "autonomi-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "MaidSafe Developers <dev@maidsafe.net>",
    "author_email": "MaidSafe Developers <dev@maidsafe.net>",
    "download_url": null,
    "platform": null,
    "description": "# Autonomi Python Bindings\n\nThe Autonomi client library provides Python bindings for easy integration with Python applications.\n\n## Installation\n\nWe recommend using `uv` for Python environment management:\n\n```bash\nuv venv\nuv pip install autonomi-client\n```\n\n## Quick Start\n\n```python\nfrom autonomi_client import Client, Wallet, PaymentOption\n\n# Initialize wallet with private key\nwallet = Wallet(\"your_private_key_here\")\nprint(f\"Wallet address: {wallet.address()}\")\nprint(f\"Balance: {wallet.balance()}\")\n\n# Connect to network\nclient = Client.connect([\"/ip4/127.0.0.1/tcp/12000\"])\n\n# Create payment option\npayment = PaymentOption.wallet(wallet)\n\n# Upload data\ndata = b\"Hello, Safe Network!\"\naddr = client.data_put_public(data, payment)\nprint(f\"Data uploaded to: {addr}\")\n\n# Download data\nretrieved = client.data_get_public(addr)\nprint(f\"Retrieved: {retrieved.decode()}\")\n```\n\n## API Reference\n\n### Client\n\nThe main interface to interact with the Autonomi network.\n\n#### Connection Methods\n\n- `connect(peers: List[str]) -> Client`\n  - Connect to network nodes\n  - `peers`: List of multiaddresses for initial network nodes\n\n#### Data Operations\n\n- `data_put_public(data: bytes, payment: PaymentOption) -> str`\n  - Upload public data to the network\n  - Returns address where data is stored\n\n- `data_get_public(addr: str) -> bytes`\n  - Download public data from the network\n  - `addr`: Address returned from `data_put_public`\n\n- `data_put(data: bytes, payment: PaymentOption) -> DataMapChunk`\n  - Store private (encrypted) data\n  - Returns access information for later retrieval\n\n- `data_get(access: DataMapChunk) -> bytes`\n  - Retrieve private data\n  - `access`: DataMapChunk from previous `data_put`\n\n#### Pointer Operations\n\n- `pointer_get(address: str) -> Pointer`\n  - Retrieve pointer from network\n  - `address`: Hex-encoded pointer address\n\n- `pointer_put(pointer: Pointer, wallet: Wallet)`\n  - Store pointer on network\n  - Requires payment via wallet\n\n- `pointer_cost(key: VaultSecretKey) -> str`\n  - Calculate pointer storage cost\n  - Returns cost in atto tokens\n\n#### Vault Operations\n\n- `vault_cost(key: VaultSecretKey) -> str`\n  - Calculate vault storage cost\n\n- `write_bytes_to_vault(data: bytes, payment: PaymentOption, key: VaultSecretKey, content_type: int) -> str`\n  - Write data to vault\n  - Returns vault address\n\n- `fetch_and_decrypt_vault(key: VaultSecretKey) -> Tuple[bytes, int]`\n  - Retrieve vault data\n  - Returns (data, content_type)\n\n- `get_user_data_from_vault(key: VaultSecretKey) -> UserData`\n  - Get user data from vault\n\n- `put_user_data_to_vault(key: VaultSecretKey, payment: PaymentOption, user_data: UserData) -> str`\n  - Store user data in vault\n  - Returns vault address\n\n### Wallet\n\nEthereum wallet management for payments.\n\n- `new(private_key: str) -> Wallet`\n  - Create wallet from private key\n  - `private_key`: 64-char hex string without '0x' prefix\n\n- `address() -> str`\n  - Get wallet's Ethereum address\n\n- `balance() -> str`\n  - Get wallet's token balance\n\n- `balance_of_gas() -> str`\n  - Get wallet's gas balance\n\n### PaymentOption\n\nConfigure payment methods.\n\n- `wallet(wallet: Wallet) -> PaymentOption`\n  - Create payment option from wallet\n\n### Pointer\n\nHandle network pointers for referencing data.\n\n- `new(target: str) -> Pointer`\n  - Create new pointer\n  - `target`: Hex-encoded target address\n\n- `address() -> str`\n  - Get pointer's network address\n\n- `target() -> str`\n  - Get pointer's target address\n\n### VaultSecretKey\n\nManage vault access keys.\n\n- `new() -> VaultSecretKey`\n  - Generate new key\n\n- `from_hex(hex: str) -> VaultSecretKey`\n  - Create from hex string\n\n- `to_hex() -> str`\n  - Convert to hex string\n\n### UserData\n\nManage user data in vaults.\n\n- `new() -> UserData`\n  - Create new user data\n\n- `add_file_archive(archive: str) -> Optional[str]`\n  - Add file archive\n  - Returns archive ID if successful\n\n- `add_private_file_archive(archive: str) -> Optional[str]`\n  - Add private archive\n  - Returns archive ID if successful\n\n- `file_archives() -> List[Tuple[str, str]]`\n  - List archives as (id, address) pairs\n\n- `private_file_archives() -> List[Tuple[str, str]]`\n  - List private archives as (id, address) pairs\n\n### DataMapChunk\n\nHandle private data storage references.\n\n- `from_hex(hex: str) -> DataMapChunk`\n  - Create from hex string\n\n- `to_hex() -> str`\n  - Convert to hex string\n\n- `address() -> str`\n  - Get short reference address\n\n### Utility Functions\n\n- `encrypt(data: bytes) -> Tuple[bytes, List[bytes]]`\n  - Self-encrypt data\n  - Returns (data_map, chunks)\n\n## Examples\n\nSee the `examples/` directory for complete examples:\n- `autonomi_example.py`: Basic data operations\n- `autonomi_pointers.py`: Working with pointers\n- `autonomi_vault.py`: Vault operations\n- `autonomi_private_data.py`: Private data handling\n- `autonomi_private_encryption.py`: Data encryption\n- `autonomi_advanced.py`: Advanced usage scenarios\n\n## Best Practices\n\n1. Always handle wallet private keys securely\n2. Check operation costs before executing\n3. Use appropriate error handling\n4. Monitor wallet balance for payments\n5. Use appropriate content types for vault storage\n6. Consider using pointers for updatable references\n7. Properly manage and backup vault keys\n\nFor more examples and detailed usage, see the examples in the repository.\n\n",
    "bugtrack_url": null,
    "license": "GPL-3.0",
    "summary": "Autonomi client API",
    "version": "0.3.61",
    "project_urls": {
        "Homepage": "https://maidsafe.net",
        "Repository": "https://github.com/maidsafe/autonomi"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e10443448a4ca46e176d76240a484520475b2af198a6355cdd46dac6d552a753",
                "md5": "fb320b438837c408afd693ebb9fa4d8f",
                "sha256": "aecd9b828cc2d3893bf551dec91fac0fff5968f630df6a2907f5017f007f81be"
            },
            "downloads": -1,
            "filename": "autonomi_client-0.3.61-cp38-abi3-macosx_10_12_x86_64.whl",
            "has_sig": false,
            "md5_digest": "fb320b438837c408afd693ebb9fa4d8f",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 9669505,
            "upload_time": "2025-02-12T17:51:17",
            "upload_time_iso_8601": "2025-02-12T17:51:17.177628Z",
            "url": "https://files.pythonhosted.org/packages/e1/04/43448a4ca46e176d76240a484520475b2af198a6355cdd46dac6d552a753/autonomi_client-0.3.61-cp38-abi3-macosx_10_12_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4f141418195cc8dd6015ad863dbc497fd1338162ccae53067fbd890353f09c69",
                "md5": "2a0da6a7dfc177a4e5ad8836498de29f",
                "sha256": "215d1029b50912e091f531b93016770fd19bdfa5ef8ff3aae2fdecf185ddf33e"
            },
            "downloads": -1,
            "filename": "autonomi_client-0.3.61-cp38-abi3-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "2a0da6a7dfc177a4e5ad8836498de29f",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 9323534,
            "upload_time": "2025-02-12T17:51:21",
            "upload_time_iso_8601": "2025-02-12T17:51:21.038948Z",
            "url": "https://files.pythonhosted.org/packages/4f/14/1418195cc8dd6015ad863dbc497fd1338162ccae53067fbd890353f09c69/autonomi_client-0.3.61-cp38-abi3-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a986db9f14e3f000ff7b9187ee6636145f19990a3d56515cc822669bc962633c",
                "md5": "2a34a5315161a0539ab8ab8a4f4bd77a",
                "sha256": "9ca3166e1fae16dafd58beb209529c4bdc725a1856861ba702fea6208bc33699"
            },
            "downloads": -1,
            "filename": "autonomi_client-0.3.61-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "2a34a5315161a0539ab8ab8a4f4bd77a",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 10625549,
            "upload_time": "2025-02-12T17:51:25",
            "upload_time_iso_8601": "2025-02-12T17:51:25.622331Z",
            "url": "https://files.pythonhosted.org/packages/a9/86/db9f14e3f000ff7b9187ee6636145f19990a3d56515cc822669bc962633c/autonomi_client-0.3.61-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2007e2d1537e88b6c68483b79f624a9a2c6421599315888fcfe58318bd16dbd3",
                "md5": "8ae223b563ed59c16cd437fbbc8b96fe",
                "sha256": "9fefc4124f4d91fe252f6d219eab225522bd4ae958c55490604a403ced779cb0"
            },
            "downloads": -1,
            "filename": "autonomi_client-0.3.61-cp38-abi3-musllinux_1_2_aarch64.whl",
            "has_sig": false,
            "md5_digest": "8ae223b563ed59c16cd437fbbc8b96fe",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 10458392,
            "upload_time": "2025-02-12T17:51:29",
            "upload_time_iso_8601": "2025-02-12T17:51:29.160921Z",
            "url": "https://files.pythonhosted.org/packages/20/07/e2d1537e88b6c68483b79f624a9a2c6421599315888fcfe58318bd16dbd3/autonomi_client-0.3.61-cp38-abi3-musllinux_1_2_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e2960d8db8176d022dd5c2808423eff65dc56729fd2ffe64c0d48826c143136f",
                "md5": "295e5b981f1952f760468a62b56ebb55",
                "sha256": "c2e3313cef2e029a8263efc2bf0b226e89536e08667403d3a9e6e7e90cb5fc71"
            },
            "downloads": -1,
            "filename": "autonomi_client-0.3.61-cp38-abi3-musllinux_1_2_armv7l.whl",
            "has_sig": false,
            "md5_digest": "295e5b981f1952f760468a62b56ebb55",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 10240916,
            "upload_time": "2025-02-12T17:51:32",
            "upload_time_iso_8601": "2025-02-12T17:51:32.063693Z",
            "url": "https://files.pythonhosted.org/packages/e2/96/0d8db8176d022dd5c2808423eff65dc56729fd2ffe64c0d48826c143136f/autonomi_client-0.3.61-cp38-abi3-musllinux_1_2_armv7l.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "81c29ae3503c56b8b6cd7725067d4b594a91b1c094e87020b559798da3ef912b",
                "md5": "0ecd9d5bd07a5af244109a445b377dba",
                "sha256": "5c8310f8dff8a7d53e0253a086461ec2758722829d462dae064a27dcfb2e4ec2"
            },
            "downloads": -1,
            "filename": "autonomi_client-0.3.61-cp38-abi3-musllinux_1_2_x86_64.whl",
            "has_sig": false,
            "md5_digest": "0ecd9d5bd07a5af244109a445b377dba",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 10681129,
            "upload_time": "2025-02-12T17:51:35",
            "upload_time_iso_8601": "2025-02-12T17:51:35.447430Z",
            "url": "https://files.pythonhosted.org/packages/81/c2/9ae3503c56b8b6cd7725067d4b594a91b1c094e87020b559798da3ef912b/autonomi_client-0.3.61-cp38-abi3-musllinux_1_2_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "90ed6df5c7903014b13310dd8184583cd5e800de22494eac6179fbfab4bde303",
                "md5": "7bfb2a69903d49efcec02417a8e2ea23",
                "sha256": "69807a127c5a7339d27e8272df8c7ee4c4fdf561982d0371ebb891a601e5a4f6"
            },
            "downloads": -1,
            "filename": "autonomi_client-0.3.61-cp38-abi3-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "7bfb2a69903d49efcec02417a8e2ea23",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 8777753,
            "upload_time": "2025-02-12T17:51:39",
            "upload_time_iso_8601": "2025-02-12T17:51:39.173616Z",
            "url": "https://files.pythonhosted.org/packages/90/ed/6df5c7903014b13310dd8184583cd5e800de22494eac6179fbfab4bde303/autonomi_client-0.3.61-cp38-abi3-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-12 17:51:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "maidsafe",
    "github_project": "autonomi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "autonomi-client"
}
        
Elapsed time: 0.45143s