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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ed9b5b88cedf45eac267fe32aab5baefae227b37fd62bac5a5880e1149dd936
|
|
| MD5 |
198bbf9382b7226e61d3d33973e628e8
|
|
| BLAKE2b-256 |
f4c7f2bb6ad929a88c2ef784aa2a95b6b2801d4eea75c2e00485044e475a7358
|
Provenance
The following attestation bundles were made for walrus_python-0.1.0.tar.gz:
Publisher:
python-publish.yml on standard-crypto/walrus-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
walrus_python-0.1.0.tar.gz -
Subject digest:
5ed9b5b88cedf45eac267fe32aab5baefae227b37fd62bac5a5880e1149dd936 - Sigstore transparency entry: 193675628
- Sigstore integration time:
-
Permalink:
standard-crypto/walrus-python@8854b6d77e6625f1d35e6bef615f379fb3dd87c6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/standard-crypto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8854b6d77e6625f1d35e6bef615f379fb3dd87c6 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2db0b04f284a165b361e3343d8d5d4e671010b043e46cc4862ebe766f6d9e807
|
|
| MD5 |
4dd2c2bba80d4f41d1e3ed56f4f4b501
|
|
| BLAKE2b-256 |
cd3f95a40cba5292b25ede249016dea851d72561c0dc39d9d733e9ce19d727f4
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
walrus_python-0.1.0-py3-none-any.whl -
Subject digest:
2db0b04f284a165b361e3343d8d5d4e671010b043e46cc4862ebe766f6d9e807 - Sigstore transparency entry: 193675629
- Sigstore integration time:
-
Permalink:
standard-crypto/walrus-python@8854b6d77e6625f1d35e6bef615f379fb3dd87c6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/standard-crypto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8854b6d77e6625f1d35e6bef615f379fb3dd87c6 -
Trigger Event:
release
-
Statement type: