Python
Sync and async clients, and the fill stream.
pmwallets-python on GitHub, pmwallets on PyPI. Python ≥ 3.10, sync and asyncio clients.
shell
pip install pmwallets
python
import asyncio from pmwallets import AsyncClient, Client, FillStream, FileStateStore # synchronous REST with Client(api_key="pmw_...") as pmw: board = pmw.leaderboard(minWinLo=0.55, minEligible=30, style="taker", status="active", limit=50) cheap = pmw.leaderboard(bands=[0, 1], minWinLo=0.55) # address unlocks free or in the cheapest paid band (0 = free ... 5) pmw.subscribe(board["rows"][0]["entityId"], channels=["ws"]) # billed per entity per hour # every fill of every entity you follow async def main(): async with AsyncClient(api_key="pmw_...") as pmw: stream = FillStream( client=pmw, store=FileStateStore("stream.json"), # a restart resumes from the last saved cursor on_fill=lambda fill, meta: print(meta.source, fill["side"], fill["price"], fill["tokenId"]), ) await stream.run() asyncio.run(main())
| What it does | |
|---|---|
Client / AsyncClient | every REST call, the same names as Node in snake_case — see the method list |
FillStream | asyncio WebSocket with reconnect and keep-alive; gap detection and replay; de-duplication; persisted cursor |
verify_webhook(raw_body, signature, secret) | checks x-pmw-signature (HMAC-SHA256 of the raw body) |