Python client library for connecting to Bee decentralised storage
Project description
๐ Bee Py
๐ Table of Contents
๐ Overview
This is the library for connecting to Bee decentralised storage using python.
โจ Features
- TODO
๐ Requirements
Python3.9+
๐ Testing Locally
๐ ๏ธ Installation
You can install bee-py
via [pip] from [PyPI]:
pip install swarm-bee-py
๐ Usage
๐ Bee Endpoint
from bee_py.bee import Bee
bee = Bee("https://18.134.10.41:1633")
# List Tags
all_tags = bee.get_all_tags({"limit": 1000})
print(all_tags)
>>> [Tag(split=0, seen=0, stored=0, sent=0, synced=6, uid=2270760008, started_at='2023-12-27T19:00:24Z', total=6, processed=6),
Tag(split=0, seen=0, stored=0, sent=0, synced=0, uid=2271272542, started_at='2023-12-09T13:22:52Z', total=0, processed=0),
Tag(split=0, seen=0, stored=0, sent=0, synced=3, uid=2272654825, started_at='2023-12-26T22:15:30Z', total=3, processed=3),
Tag(split=0, seen=0, stored=0, sent=0, synced=3, uid=2274652661, started_at='2023-12-19T20:27:27Z', total=3, processed=3),
Tag(split=0, seen=0, stored=0, sent=0, synced=4, uid=2274680401, started_at='2024-01-05T20:03:17Z', total=4, processed=4),
Tag(split=0, seen=0, stored=0, sent=0, synced=16, uid=2274738522, started_at='2023-12-27T00:12:46Z', total=16, processed=16),
Tag(split=0, seen=0, stored=0, sent=0, synced=6, uid=2277789382, started_at='2024-01-05T19:30:39Z', total=6, processed=6),
Tag(split=0, seen=0, stored=0, sent=0, synced=5, uid=2278169907, started_at='2023-12-27T00:44:34Z', total=5, processed=5),
Tag(split=0, seen=0, stored=0, sent=0, synced=1, uid=2278428847, started_at='2023-12-19T01:29:06Z', total=1, processed=1),
Tag(split=0, seen=0, stored=0, sent=0, synced=1, uid=2280360127, started_at='2023-12-27T16:18:04Z', total=1, processed=1)]
# Random Taken for example
batch_id = "eeba33ebe515c3ca9827a5e82e07987f813966fd39067126b120bcd6cd714ce9"
# Upload Data
upload_result = bee.upload_data(batch_id, "Bee is Awesome!")
print(upload_result)
>>> UploadResult(reference=Reference(value='b0d6b928d0f64fab1a50d37a965515cc6f152d3c27f58fbcefb6b8506f23b076'), tag_uid=None)
print(upload_result.reference)
>>> Reference(value='b0d6b928d0f64fab1a50d37a965515cc6f152d3c27f58fbcefb6b8506f23b076')
print(upload_result.reference.value)
>>> 'b0d6b928d0f64fab1a50d37a965515cc6f152d3c27f58fbcefb6b8506f23b076'
# Both can be done to obtain the reference value
print(str(upload_result.reference))
>>> 'b0d6b928d0f64fab1a50d37a965515cc6f152d3c27f58fbcefb6b8506f23b076'
data = bee.download_data(upload_result.reference.value)
print(data)
>>> Data(data=b'Bee is Awesome!')
# Data can be converted into json format, hex, bytes or plain-text
print(data.to_json())
>>> '{"data":"Bee is Awesome!"}'
print(data.text())
>>> 'Bee is Awesome!'
print(data.hex())
>>> '42656520697320417765736f6d6521'
๐ Bee Debug Endpoint
from bee_py.bee_debug import BeeDebug
bee_debug = BeeDebug("https://18.134.10.41:1635")
# Be aware, this creates on-chain transactions that spend Eth and BZZ!
# Get Postage
batch_id = bee_debug.create_postage_batch('2000', 20)
print(batch_id)
>>> "17cbeb913ff852e34ade49c6df75adc7ff6f263b86d59c1cb2c3b0388cfe9cf3"
๐ฉโ๐ป Development
This project is developed using pdm. So the quickest way to get started is using pdm
. Install pdm using pip
, pipx
etc & then follow the following steps
git clone https://github.com/alienrobotninja/bee-py
cd bee-py
# To install all the dev & lint dependencies
pdm install -G:all
That's it, you're environment is ready. Now install docker to run bee-factory. Now to start the bee-factory
do bee-factory start --detach 1.15.0-rc2
. As of 7th January 2024 1.15.0-rc2
is the latest release for bee-factory
which uses a very outdated versions of bee.
๐ค Contributing
Contributions are very welcome. To learn more, see the Contributor Guide.
๐ License
Distributed under the terms of the GPL 3.0 license, Bee Py is free and open source software.
๐ Issues
There are some know issues like:
- Some tests are perfomed on older versions of bee.
- Some tests are stuck for hours when using the latest Bee API(not
bee-py
issue). - Some tests are skipped because of outdated libraries used by various
ethersphere
projects.
If you encounter any problems, please [file an issue] along with a detailed description.
๐ Documentation
You can find the full documentation here. The API reference documentation can be found here.
๐ Credits
Developed by @Aviksaikat
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
Hashes for swarm_bee_py-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab82a922a3abfab17667270d2d04704c288271ac540dce1b7cde27f320b35dd2 |
|
MD5 | 0769edf113a6878fd33ebe7f74b255fd |
|
BLAKE2b-256 | 342c6c84417a38ff657a0066b80a1713cfe8ea0efc00f2608707c47fbdf7f047 |