XRL Websocket Client
Project description
XRPL Websocket
Websocket client for rippled with reconnecting feature, support both python 2 and 3
Installation
Via pip:
pip install xrpl_websocket
Examples
Short-lived connection
Simple example to send a payload and wait for response
import json
from xrpl_websocket import Client
if __name__ == "__main__":
# create instance
client = Client()
# connect to the websocket
client.connect(nowait=False)
# send server info command
resp = client.send(command='server_info')
print("Server Info:")
print(json.dumps(resp, indent = 4))
# close the connection
client.disconnect()
More advanced: Custom class
You can also write your own class for the connection, if you want to handle the nitty-gritty details yourself.
class Example(Client):
def __init__(self):
super(self.__class__, self).__init__(
log_level=logging.ERROR,
server="wss://rippled.xrptipbot.com"
)
# connect to the websocket
self.connect()
def on_transaction(self, data):
print(json.dumps(data, indent = 4))
def on_ledger(self,data):
print('on_ledger')
def on_open(self):
print("Connection is open")
print("Subscribe to ledger transactions")
self.subscribe_transactions()
def on_close(self):
print("on_close")
def subscribe_transactions(self):
self.send({
'command': 'subscribe',
'streams': ['transactions']
})
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
Close
Hashes for xrpl_websocket-0.1.0rc1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1c4982c34dbea98d4bfc773b36f24525c9b1f18c6b47e5ef2f10010201ea63e |
|
MD5 | 5849221b8283353fdbbd8f201727670c |
|
BLAKE2b-256 | ee404d0020e6f106d27c0596520dcb05f93abcd33cc208ee9b2fb48ef6ecb6e2 |