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,
    set_logger,
    AppMeta,
    Builder,
    Logger,
    UploadOptions,
)


class PrintLogger(Logger):
    def debug(self, msg): print("DEBUG", msg)
    def info(self, msg): print("INFO", msg)
    def warning(self, msg): print("WARNING", msg)
    def error(self, msg): print("ERROR", msg)


set_logger(PrintLogger(), "debug")


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

    builder = Builder(
        "https://app.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 data
    upload = await sdk.upload_packed(UploadOptions())
    await upload.add(BytesIO(b"hello, world!"))
    objects = await upload.finalize()

    # Download data
    buf = BytesIO()
    await sdk.download(buf, objects[-1])


asyncio.run(main())

PrintLogger is a user-defined class that extends the SDK's Logger base class.

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

Local Development

cd python
pip 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.4.1.tar.gz (64.4 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.4.1-py3-none-win_amd64.whl (3.4 MB view details)

Uploaded Python 3Windows x86-64

sia_storage-0.4.1-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.4.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

sia_storage-0.4.1-py3-none-macosx_10_12_x86_64.whl (3.7 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for sia_storage-0.4.1.tar.gz
Algorithm Hash digest
SHA256 326314af80377f5ff343d5e98e860b65f5ed6401c2d9ee0c20cc5f60742051c1
MD5 0c67c993a371e24ad5927fc0211509e0
BLAKE2b-256 f3f10ac1c989c62f235a80bcbd1ac9169f5bca199bd532088e9e756951e28827

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sia_storage-0.4.1-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.7

File hashes

Hashes for sia_storage-0.4.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 d7db17a1a83a22edb0342dc83268cf0365b2abb658b4952c459b39ef3ad70d60
MD5 1570e434a4da68a6f648ee6952e4d060
BLAKE2b-256 5c707c79d75d1ef26cbff1f5ea21a982c751571c8106b9617e7c668044c5a1e9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sia_storage-0.4.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 392fd63042a45434cb16b94f5db17c9599be202fe3c56e5c2904408d0bfbe2af
MD5 d348740cccc5410b6390b1b634ced73d
BLAKE2b-256 b7c34b08d1e5c64dfbdf9ad3099919ba79351b08ca19b7352f32418c585de299

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sia_storage-0.4.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 de5ea924fc220b2743ae4a8e54ce0f554e4671fc68c2c2dbfeedfb937bf4f4a6
MD5 8c4ef4a15415e282c2823fa55f2c1e93
BLAKE2b-256 fae3f321121fb49cf590db2a25550a7e29c6735430358ec66e16b058718ea13f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sia_storage-0.4.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 16560db3eb29222d1e2e7d5d5ac523b32c08abd10ec6fc75424fa7ad054d7a3c
MD5 81c4d27fb4829073687c76c1fac70aa8
BLAKE2b-256 a5572a695a8252606c591a0e4090dda86c65ea9be309ab3c4d51febb64267716

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sia_storage-0.4.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7c0d8f266d639d7e12588ae3f83ec3e9022bd0ea26aeadfb04c5847a73ac4ca5
MD5 12f631bcbb64d76b47cd7b19c9f37544
BLAKE2b-256 2887febc277130b27c073f17a49ac7ab0b022940ad8af26221d237c7bb052a30

See more details on using hashes here.

Provenance

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