Skip to main content

Python SDK for Walrus, a decentralized blob storage protocol

Project description

Walrus Python SDK

The walrus-python SDK provides a Python client for interacting with the Walrus HTTP API. Walrus is a decentralized storage system built on the Sui blockchain, allowing you to store and retrieve blobs efficiently.

PyPI License Tests

Installation

pip install walrus-python

Usage

Initializing the Client

from walrus import WalrusClient

publisher_url = "https://publisher.walrus-testnet.walrus.space"
aggregator_url = "https://aggregator.walrus-testnet.walrus.space"

client = WalrusClient(publisher_base_url=publisher_url, aggregator_base_url=aggregator_url)

Uploading a Blob

Available Parameters

  • encoding_type (Optional[str]): Specifies the encoding used for the blob.

  • epochs (Optional[int]): Number of epochs ahead of the current one to store the blob.

  • deletable (Optional[bool]): Determines whether the blob can be deleted later (True) or is permanent (False).

  • send_object_to (Optional[str]): If provided, sends the Blob object to the specified Sui address.

From Bytes

blob_data = b"Hello Walrus!"
response = client.put_blob(data=blob_data)
print(response)

From a File

file_path = "path/to/your/file.txt"
response = client.put_blob_from_file(file_path)
print(response)

From a Binary Stream

url = "https://example.com/stream"
with requests.get(url, stream=True) as response:
    result = client.put_blob_from_stream(response.raw)
    print(result)

Retrieving a Blob

By Blob ID

blob_id = "your-blob-id"
blob_content = client.get_blob(blob_id)
print(blob_content)

By Object ID

object_id = "your-object-id"
blob_content = client.get_blob_by_object_id(object_id)
print(blob_content)

As a File

blob_id = "your-blob-id"
destination_path = "downloaded_blob.jpg"
client.get_blob_as_file(blob_id, destination_path)
print(f"Blob saved to {destination_path}")

As a Stream

blob_id = "your-blob-id"
stream = client.get_blob_as_stream(blob_id)
with open("streamed_blob.bin", "wb") as f:
    f.write(stream.read())

Retrieving Blob Metadata

blob_id = "your-blob-id"
metadata = client.get_blob_metadata(blob_id)
print(metadata)

Error Handling

WalrusAPIError provides structured error information:

try:
    client.get_blob("non-existent-id")
except WalrusAPIError as e:
    print(e)

Contributing

Contributions are welcome! Please submit a pull request or open an issue for any suggestions, improvements, or bug reports.

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

walrus_python-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

walrus_python-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file walrus_python-0.1.0.tar.gz.

File metadata

  • Download URL: walrus_python-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for walrus_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5ed9b5b88cedf45eac267fe32aab5baefae227b37fd62bac5a5880e1149dd936
MD5 198bbf9382b7226e61d3d33973e628e8
BLAKE2b-256 f4c7f2bb6ad929a88c2ef784aa2a95b6b2801d4eea75c2e00485044e475a7358

See more details on using hashes here.

Provenance

The following attestation bundles were made for walrus_python-0.1.0.tar.gz:

Publisher: python-publish.yml on standard-crypto/walrus-python

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

File details

Details for the file walrus_python-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: walrus_python-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for walrus_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2db0b04f284a165b361e3343d8d5d4e671010b043e46cc4862ebe766f6d9e807
MD5 4dd2c2bba80d4f41d1e3ed56f4f4b501
BLAKE2b-256 cd3f95a40cba5292b25ede249016dea851d72561c0dc39d9d733e9ce19d727f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for walrus_python-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on standard-crypto/walrus-python

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