import asyncio
import json
import websockets
API_KEY = "pn_live_..."
URL = f"wss://hyper.polynode.dev/ws?key={API_KEY}"
async def main():
async with websockets.connect(URL) as ws:
# Subscribe to all fills across every market
await ws.send(json.dumps({
"action": "subscribe",
"filters": {"action_types": ["fill"]}
}))
async for raw in ws:
event = json.loads(raw)
# Ignore the subscription ack
if event.get("action") == "subscribed":
print(f"Subscribed (sub_id={event.get('sub_id')})")
continue
if event.get("type") == "fill":
data = event["data"]
print(f"{data['coin']} {data['sz']}@{data['px']} {data['dir']}")
asyncio.run(main())