Skip to main content

Streaming Client for Hyperion History API

Project description

Hyperion Stream Client

PyPi Version GitHub

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

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hyperion_stream_client-1.0.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hyperion_stream_client-1.0.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

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

Hashes for hyperion_stream_client-1.0.1.tar.gz
Algorithm Hash digest
SHA256 01653e8c14d8968bb183ff90097c76df6f0b5ab4be7a5309b5b061c35a948d6c
MD5 3673c3fff09c9a81dd940f9cc66a0462
BLAKE2b-256 888a1a8e5f7a498ee92c27db87324d7ac3f73f048161830cde88820669c06667

See more details on using hashes here.

File details

Details for the file hyperion_stream_client-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for hyperion_stream_client-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bc83c3d49780ae7d7a32ba0913a27f1e681fdd5d1a75cdf18628375297f5df34
MD5 7b4f7328830d76e11536b9e39896ad0d
BLAKE2b-256 f7fff4cc0daa0ed3151307f5221b69fa7540248235089f1bbccd1d9bd7ae1d6c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page