Skip to main content

Requirements

  • Python 3.7 or higher
  • pip

Installation

1

Install dependencies

2

Copy the SDK files

Download polyedge.py, parser_compact_tx.py, and sseclient.py from the PolyEdge examples repository and copy them into your project directory.
sseclient.py is a lightweight, MIT-licensed Server-Sent Events client bundled with the SDK — no additional SSE library is required.

Instantiation

Import PolyEdgeClient and pass your API key. The base URL defaults to https://api.polyedge.dev/v1.
You can also pass a custom base URL as the second argument:
Your API key is sent on every request via the X-PolyEdge-Key header.

Methods

Retrieve the trader leaderboard, optionally filtered and sorted.
Parametersparams is an optional dict:Returns dict.
Get a trader’s detailed profile including tags, stats, and metadata.
Returns dict.
Retrieve a trader’s trading history aggregated by market.
Returns dict.
Retrieve a specific trader’s order history within a specific market.
Returns dict.
Get hourly aggregated performance data for a specific trader.
Returns dict.
Retrieve detailed information about a specific market.
Returns dict.
Subscribe to live mempool orders via SSE. Returns a generator that yields parsed order dicts.
Break out of the loop at any time to stop consuming the stream.Parametersparams is an optional dict:Yields dict.
When format is omitted, each yielded value is the output of parse_compact_tx — a fully structured Python dict. See Compact format parsing below.

Compact format parsing

By default, stream_orders receives events in a compact array format optimised for low bandwidth. The parser_compact_tx.py utility converts each raw list into a structured dict before yielding it. The parsed dict has this shape:
USDC and shares values are returned as raw strings in 1e6 format. Divide by 1e6 to convert to human-readable amounts: float(order['takerOrder']['usdc']) / 1e6.
If you prefer fully structured JSON from the API rather than parsing compact arrays yourself, pass format='json' in the params dict to stream_orders — the raw response is yielded directly without calling the parser.

Complete example

The following example exercises every method in the SDK, then opens the SSE stream and prints the first three events.