Python bindings for libstreamrproxyclient
Project description
Python wrapper for the StreamrProxyClient
This is a Python wrapper for the StreamrProxyClient C++ library. It is used to publish data to the Streamr network.
Installation
python -m pip install libstreamrproxyclient
The package is distributed as a binary wheel and is available for MacOS (arm64 and x86_64) and Linux (arm64 and x86_64).
Usage example
from streamrproxyclient.libstreamrproxyclient import (
Proxy,
LibStreamrProxyClient,
ProxyClient
)
proxy_ethereum_address = "0xd0d14b38d1f6b59d3772a63d84ece0a79e6e1c1f"
proxy_url = "ws://95.216.15.80:44211"
stream_part_id = "0xd2078dc2d780029473a39ce873fc182587be69db/low-level-client#0"
own_ethereum_address = "0xa5374e3c19f15e1847881979dd0c6c9ffe846bd5"
ethereum_private_key = "23bead9b499af21c4c16e4511b3b6b08c3e22e76e0591f5ab5ba8d4c3a5b1820"
with LibStreamrProxyClient() as lib:
with ProxyClient(lib, own_ethereum_address, stream_part_id) as client:
result = client.connect([Proxy(proxy_url, proxy_ethereum_address)])
assert len(result.errors) == 0
assert len(result.successful) == 1
result = client.publish(b"Hello from python!", ethereum_private_key)
assert len(result.errors) == 0
assert len(result.successful) == 1
API documentation
Classes
Proxy
Contains information about a proxy node in the Streamr network.
Methods:
__init__(websocket_url: str, ethereum_address: str): Initialize a Proxy instance with websocket URL and Ethereum addressfrom_c_proxy(c_proxy): Create Proxy instance from C struct (internal use)
Error
Represents an error from the C library.
Attributes:
message: Error message stringcode: Error code stringproxy: Associated Proxy instance if applicable
ProxyClientException
Exception raised when C library operations fail.
Attributes:
error: The Error instance containing details
ProxyClientResult
Result of proxy client operations.
Attributes:
errors: List of Error instances if operation had errorssuccessful: List of successful Proxy instances
LibStreamrProxyClient
Wrapper for the C library. Use as context manager.
Methods:
__enter__(): Load and initialize C library__exit__(): Cleanup C library
ProxyClient
Main client for interacting with proxies. Use as context manager.
Methods:
__init__(lib: LibStreamrProxyClient, ownEthereumAddress: str, streamPartId: str): Initialize with library instance, Ethereum address and stream IDconnect(proxies: list[Proxy]) -> ProxyClientResult: Connect to list of proxiespublish(data: bytes, ethereumPrivateKey: str = None) -> ProxyClientResult: Publish data to connected proxies
Error Codes
ERROR_INVALID_ETHEREUM_ADDRESS: Invalid Ethereum address formatERROR_INVALID_STREAM_PART_ID: Invalid stream part ID formatERROR_PROXY_CLIENT_NOT_FOUND: Proxy client instance not foundERROR_INVALID_PROXY_URL: Invalid proxy websocket URLERROR_NO_PROXIES_DEFINED: No proxies providedERROR_PROXY_CONNECTION_FAILED: Failed to connect to proxyERROR_PROXY_BROADCAST_FAILED: Failed to broadcast message to proxy
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 libstreamrproxyclient-2.0.5.tar.gz.
File metadata
- Download URL: libstreamrproxyclient-2.0.5.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71a6b06b1f8350c1c9a8b95876910756b3480f263f3a30901ced2965b202dd2b
|
|
| MD5 |
f43feaa780c0d4f9921e37bce65a033e
|
|
| BLAKE2b-256 |
f7a17beabf63651e7689e1b0f7028c02fd1694d35f37ab7333b259943fc56484
|
File details
Details for the file libstreamrproxyclient-2.0.5-py3-none-macosx_13_6_arm64.whl.
File metadata
- Download URL: libstreamrproxyclient-2.0.5-py3-none-macosx_13_6_arm64.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3, macOS 13.6+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa68e7dd55aa30b4e5a3d5731893f7ff26e662a04dfe613fcce0f463e1437630
|
|
| MD5 |
3d13e5cf165372f2407e9a58b4e9d583
|
|
| BLAKE2b-256 |
754cdb591f23da2f67a8ad30dcaeec3a299ac344747674de4609ffede465ee34
|