Skip to main content

Python SDK for interacting with the Sia decentralized storage network

Project description

Sia Storage SDK for Python

Python bindings for Sia Storage, built with Rust and UniFFI.

Requirements

  • Python 3.9+

Installation

PyPI

pip install sia-storage

Example

import asyncio
from io import BytesIO

from sia_storage import (
    generate_recovery_phrase,
    AppMetadata,
    Builder,
    DownloadOptions,
    PinnedObject,
    UploadOptions,
)


async def main():
    app_id = b"\x01" * 32

    builder = Builder(
        "https://sia.storage",
        AppMetadata(
            id=app_id,
            name="My App",
            description="App description",
            service_url="https://myapp.com",
            logo_url=None,
            callback_url=None,
        ),
    )
    await builder.request_connection()

    # Wait for user approval
    print(f"Please approve connection {builder.response_url()}")
    await builder.wait_for_approval()

    # Register with a recovery phrase
    mnemonic = generate_recovery_phrase()
    sdk = await builder.register(mnemonic)

    # Upload a single object. Progress callbacks accept plain callables.
    def on_upload(p):
        print(f"uploaded shard {p.shard_index} of slab {p.slab_index} in {p.elapsed_ms}ms")

    obj = await sdk.upload(
        PinnedObject(),
        BytesIO(b"hello, world!"),
        UploadOptions(shard_uploaded=on_upload),
    )
    await sdk.pin_object(obj)

    # Download streams via an async context manager.
    def on_download(p):
        print(f"downloaded shard {p.shard_index} of slab {p.slab_index} in {p.elapsed_ms}ms")

    async with sdk.download(obj, DownloadOptions(shard_downloaded=on_download)) as d:
        data = await d.read_all()
    print(data)


asyncio.run(main())

A complete working example is available in examples/python/.

Local Development

cd python
python3 -m venv .venv
source .venv/bin/activate
pip3 install maturin

# Build and install the wheel
maturin develop

# Run the example
cd ../examples/python
python example.py

License

MIT License - see LICENSE for details.

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

sia_storage-0.8.0.tar.gz (68.1 kB view details)

Uploaded Source

Built Distributions

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

sia_storage-0.8.0-py3-none-win_amd64.whl (3.4 MB view details)

Uploaded Python 3Windows x86-64

sia_storage-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

sia_storage-0.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

sia_storage-0.8.0-py3-none-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

sia_storage-0.8.0-py3-none-macosx_10_12_x86_64.whl (3.6 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file sia_storage-0.8.0.tar.gz.

File metadata

  • Download URL: sia_storage-0.8.0.tar.gz
  • Upload date:
  • Size: 68.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sia_storage-0.8.0.tar.gz
Algorithm Hash digest
SHA256 c497aa25447d13cb917d3da5ac3be9ea4967d9d38683e2a6d782114bcd57ea56
MD5 4f70b5ca78f2c35bcc73336d6150fc3b
BLAKE2b-256 d5aa9e329bce3809e2045d5cd9260b031a5551f015d88481bcfa53f6cedc8be5

See more details on using hashes here.

Provenance

The following attestation bundles were made for sia_storage-0.8.0.tar.gz:

Publisher: python.yml on SiaFoundation/sia-storage-sdk

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

File details

Details for the file sia_storage-0.8.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: sia_storage-0.8.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sia_storage-0.8.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 488a6e0365fef318122c6406f394d5c99e273a7ce6c684cda88dc80ce5c5e76a
MD5 79e9f079acea7be62702adf02d518f0b
BLAKE2b-256 5c3da2be6e304a994c2d5ba39f76ba2cc7649ba08b1dc1909d87e9ddb929b396

See more details on using hashes here.

Provenance

The following attestation bundles were made for sia_storage-0.8.0-py3-none-win_amd64.whl:

Publisher: python.yml on SiaFoundation/sia-storage-sdk

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

File details

Details for the file sia_storage-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sia_storage-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 14f8d60a27e58cb245966b55f26e2e0059c583fff2c9deb3290631f65d1438a4
MD5 d115043581bb7ea5d128d56a3e37f855
BLAKE2b-256 efcd4a458ee6cdf66b8f6148643102c553cfcfe3971917c81d5ff6aefc5181c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for sia_storage-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python.yml on SiaFoundation/sia-storage-sdk

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

File details

Details for the file sia_storage-0.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for sia_storage-0.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 209f71c31589184b8b2cafd978b610f44c6f8365645d9d18635f89c92bca6588
MD5 626638124e0bc5d85b1ec10324b2a17c
BLAKE2b-256 d6553c2f6ebc4424a2988cf71704592614055eaab2cba59a9a63560a3a86cd13

See more details on using hashes here.

Provenance

The following attestation bundles were made for sia_storage-0.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: python.yml on SiaFoundation/sia-storage-sdk

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

File details

Details for the file sia_storage-0.8.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sia_storage-0.8.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 865bc63a026be3789f16a57eeb36d695672c140fb9c465e7bebd07d7221ef1e7
MD5 41f4c95949dac55027448da8319f553f
BLAKE2b-256 ff644465a53f222ba731d8fa68a501ad9b448466f681f6a643a745e84d150f03

See more details on using hashes here.

Provenance

The following attestation bundles were made for sia_storage-0.8.0-py3-none-macosx_11_0_arm64.whl:

Publisher: python.yml on SiaFoundation/sia-storage-sdk

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

File details

Details for the file sia_storage-0.8.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for sia_storage-0.8.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6ce97e8b3c039a321c853af4e86094db82289d68f4991973eb70427012956353
MD5 df4f5b5acf53a169ca065afbde63aeb5
BLAKE2b-256 91ab5fe56e2cbc9e373f23715d2cea71d3101a48ad0572661387149a374e9018

See more details on using hashes here.

Provenance

The following attestation bundles were made for sia_storage-0.8.0-py3-none-macosx_10_12_x86_64.whl:

Publisher: python.yml on SiaFoundation/sia-storage-sdk

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