Skip to content

Python SDK for interacting with the Relayer WS API. This can be used to fetch various data-feeds supported by Yggdrasil's Data Engine.

License

Notifications You must be signed in to change notification settings

Yggdrasil-Protocol/Relayer-Python-SDK

Repository files navigation

Relayer-Python-SDK CC BY-NC-SA 4.0

Relayer-Go-SDK by Yggdrasil-Protocol is licensed under CC BY-NC-SA 4.0

Example

Here is an example of how to use the Relayer-Python-SDK:

import asyncio
from relayer_python_sdk.ws import RelayerWS
from relayer_python_sdk import events

feedIDs = ["SPOT:BTC_USDT", "SPOT:ETH_USDT"]
ws = RelayerWS(feedIDs)


@ws.on_data_event
async def on_data_event(event: events.DataFeed):
    print("Data Feed Event:", event)


@ws.on_info_event
async def on_info_event(event: events.SubscriptionMsg):
    print("Info event:", event)


async def main():
    sub_task = asyncio.create_task(ws.connect())

    await asyncio.sleep(10)
    await ws.close()

    await sub_task


if __name__ == "__main__":
    asyncio.run(main())

This code will subscribe to the data feeds SPOT:BTC_USDT and SPOT:ETH_USDT and print the price events and info events.

About

Python SDK for interacting with the Relayer WS API. This can be used to fetch various data-feeds supported by Yggdrasil's Data Engine.

Resources

License

Stars

Watchers

Forks

Languages