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,
    AppMeta,
    Builder,
    DownloadOptions,
    PinnedObject,
    UploadOptions,
)


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

    builder = Builder(
        "https://sia.storage",
        AppMeta(
            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.7.0.tar.gz (65.7 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.7.0-py3-none-win_amd64.whl (3.5 MB view details)

Uploaded Python 3Windows x86-64

sia_storage-0.7.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

sia_storage-0.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

sia_storage-0.7.0-py3-none-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

sia_storage-0.7.0-py3-none-macosx_10_12_x86_64.whl (3.8 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: sia_storage-0.7.0.tar.gz
  • Upload date:
  • Size: 65.7 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.7.0.tar.gz
Algorithm Hash digest
SHA256 a175a2647af81f665faf420002c22af10a0906e6b1ea86856f10decdd2ef3f1d
MD5 4448f2bf3f3d90735487932fa0d06284
BLAKE2b-256 fc669476ee207af3993be6c0b52273d3de05a4aff9c3c771bd7b369afe6c0551

See more details on using hashes here.

Provenance

The following attestation bundles were made for sia_storage-0.7.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.7.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: sia_storage-0.7.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.7.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 4cb364245b816ef3389c4f57033c41b3be5b103165bfcebfd7503226a7aa8b0e
MD5 50d910bc4dac980330259cd851f6bb0c
BLAKE2b-256 82caa201cc6616e9b34914b0e244070ea59d2fe0f9d4630b3c5f698562797427

See more details on using hashes here.

Provenance

The following attestation bundles were made for sia_storage-0.7.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.7.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sia_storage-0.7.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ef28e73e6b5ed99d5d06bae1be9f6ca12768fde1bfb4930b7dd4c7b9982e7212
MD5 e3b6e3adbaba711c7865f875a94c750f
BLAKE2b-256 017c9a020ab48294c0dd3cf6e4ce15cb727fd70dec5258ed4e1027865134bedd

See more details on using hashes here.

Provenance

The following attestation bundles were made for sia_storage-0.7.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.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for sia_storage-0.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 090bd158058499fa04cc5a2c073c7b17c6745e0c21ea3b95677230cb2b4b9a0f
MD5 eea98360820f9d4e7949605c4d04b605
BLAKE2b-256 2224c6d02adb5f67df4c4220112ac6186c96ebcd4962af3426e292f0ee4c51a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for sia_storage-0.7.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.7.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sia_storage-0.7.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 720961080a3392c7c3397415daf025c4d609d8e9fe572a949b2068ad0f3294ab
MD5 580cae3d16616b88791efe77f2131c8d
BLAKE2b-256 56769e90d9f8b2b9b3bc8f9eca2b29b4dad6f20eee9fd99eb07b535d681c163d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sia_storage-0.7.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.7.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for sia_storage-0.7.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3055fd037af593abb0b63f4054e078bb910a3193c2b139a88300955a9fb32343
MD5 63e88210a95fd290063e939efede7841
BLAKE2b-256 7ac847fcab300ca2161f966389119f7df0b9957b00653ae427c56d9c8f903117

See more details on using hashes here.

Provenance

The following attestation bundles were made for sia_storage-0.7.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