Skip to main content

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 address
  • from_c_proxy(c_proxy): Create Proxy instance from C struct (internal use)

Error

Represents an error from the C library.

Attributes:

  • message: Error message string
  • code: Error code string
  • proxy: 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 errors
  • successful: 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 ID
  • connect(proxies: list[Proxy]) -> ProxyClientResult: Connect to list of proxies
  • publish(data: bytes, ethereumPrivateKey: str = None) -> ProxyClientResult: Publish data to connected proxies

Error Codes

  • ERROR_INVALID_ETHEREUM_ADDRESS: Invalid Ethereum address format
  • ERROR_INVALID_STREAM_PART_ID: Invalid stream part ID format
  • ERROR_PROXY_CLIENT_NOT_FOUND: Proxy client instance not found
  • ERROR_INVALID_PROXY_URL: Invalid proxy websocket URL
  • ERROR_NO_PROXIES_DEFINED: No proxies provided
  • ERROR_PROXY_CONNECTION_FAILED: Failed to connect to proxy
  • ERROR_PROXY_BROADCAST_FAILED: Failed to broadcast message to proxy

Release files for libstreamrproxyclient 2.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libstreamrproxyclient 2.0.5
File Size Uploaded
libstreamrproxyclient-2.0.5.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for libstreamrproxyclient 2.0.5
File Interpreter ABI Platform
libstreamrproxyclient-2.0.5-py3-none-macosx_13_6_arm64.whl Python 3 none macosx 13 6 arm64 Details

Total release size: 10.0 kB

Release files / libstreamrproxyclient-2.0.5.tar.gz

Download URL libstreamrproxyclient-2.0.5.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
71a6b06b1f8350c1c9a8b95876910756b3480f263f3a30901ced2965b202dd2b
BLAKE2b-256 checksum
How to use checksums
f7a17beabf63651e7689e1b0f7028c02fd1694d35f37ab7333b259943fc56484
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.2

Release files / libstreamrproxyclient-2.0.5-py3-none-macosx_13_6_arm64.whl

Download URL libstreamrproxyclient-2.0.5-py3-none-macosx_13_6_arm64.whl
Size 5.1 kB
Tags Python 3 macosx 13 6 arm64
SHA-256 checksum
How to use checksums
fa68e7dd55aa30b4e5a3d5731893f7ff26e662a04dfe613fcce0f463e1437630
BLAKE2b-256 checksum
How to use checksums
754cdb591f23da2f67a8ad30dcaeec3a299ac344747674de4609ffede465ee34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.2

Release history Release notifications | RSS feed

This release

2.0.5 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page