Support for email/password authentication will be dropped in the future and cryptographic keys/wallets will be the only supported method.
By using this client, you can easily interact with the Streamr API from python environments. You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.
This library is work-in-progress
-
download
-
cd streamr-client-python
-
pip install .
You can test the integration functions using the following steps.
client_test.py
: you can run following commands to test.
$ cd streamr-client-python
$ pytest
Here are some quick examples.
from streamr import Client, Option
option = Option.get_default_option()
option.api_key = 'your-api-key'
option.auto_connect = False
option.auto_disconnect = False
client = Client(option)
stream = client.get_or_create_stream('stream-test')
stream_id = stream[0]['id']
stream = client.get_stream_by_name('stream-test')
stream = client.get_stream_by_id(stream_id)
print(client.connection.state)
client.connect()
while(not client.is_connected()):
pass
def callback(msg,_):
print('message received . The Content is : %s'%(msg))
subscription = client.subscribe(stream_id, callback)
import time
data = [{"name":'google',"age":19},{"name":"yahoo","age":11},{"name":"facebook","age":13},{"name":"twitter","age":1}]
stream_id = 'your stream ID'
for d in data:
client.publish(subscription, d)
time.sleep(0.01)
client.disconnect()