Streaming Client for Hyperion History API
Project description
Hyperion Stream Client
Installation
PyPI
pip install -U hyperion-stream-client
Usage
from contextlib import suppress
from hyperion.hyperion_stream_client import HyperionClientOptions, HyperionStreamClient, StreamActionsRequest
import asyncio
async def data_handler(data):
print(data)
async def main():
options = HyperionClientOptions(
endpoint="https://proton.eosusa.io", debug=True, lib_stream=False
)
client = HyperionStreamClient(options)
# Set the custom handler
client.async_data_handler = data_handler
try:
# Connect the client
await client.connect()
# Stream actions
await client.stream_actions(
StreamActionsRequest(
contract="swap.alcor",
account="swap.alcor",
action="logswap",
start_from="LIB",
read_until=0,
)
)
except Exception as e:
print(f"Error: {e}")
while True:
await asyncio.sleep(1)
if __name__ == "__main__":
with suppress(KeyboardInterrupt):
asyncio.run(main())
Class
from contextlib import suppress
from hyperion.hyperion_stream_client import HyperionClientOptions,HyperionStreamClient,StreamActionsRequest
import asyncio
class EventListener(HyperionStreamClient):
def __init__(self):
options = HyperionClientOptions(
endpoint="https://proton.eosusa.io", debug=True, lib_stream=False
)
super().__init__(options)
self.async_data_handler = self.data_handler
self.async_lib_data_handler = self.lib_data_handler
async def start(self):
# Make connection first
try:
await self.connect()
# Stream Actions
await self.stream_actions(
StreamActionsRequest(
contract="swap.alcor",
account="swap.alcor",
action="logswap",
start_from="LIB",
read_until=0,
)
)
except Exception as e:
print(e)
while True:
await asyncio.sleep(1)
async def data_handler(self, data):
print(data)
async def lib_data_handler(self, data):
print(data)
if __name__ == "__main__":
with suppress(KeyboardInterrupt) as _err:
asyncio.run(EventListener().start())
License
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 hyperion_stream_client-1.0.1.tar.gz.
File metadata
- Download URL: hyperion_stream_client-1.0.1.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01653e8c14d8968bb183ff90097c76df6f0b5ab4be7a5309b5b061c35a948d6c
|
|
| MD5 |
3673c3fff09c9a81dd940f9cc66a0462
|
|
| BLAKE2b-256 |
888a1a8e5f7a498ee92c27db87324d7ac3f73f048161830cde88820669c06667
|
File details
Details for the file hyperion_stream_client-1.0.1-py3-none-any.whl.
File metadata
- Download URL: hyperion_stream_client-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc83c3d49780ae7d7a32ba0913a27f1e681fdd5d1a75cdf18628375297f5df34
|
|
| MD5 |
7b4f7328830d76e11536b9e39896ad0d
|
|
| BLAKE2b-256 |
f7fff4cc0daa0ed3151307f5221b69fa7540248235089f1bbccd1d9bd7ae1d6c
|