Requirements
- Python 3.7 or higher
- pip
Installation
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
ImportPolyEdgeClient and pass your API key. The base URL defaults to https://api.polyedge.dev/v1.
X-PolyEdge-Key header.
Methods
get_leaderboard(params)
get_leaderboard(params)
Retrieve the trader leaderboard, optionally filtered and sorted.Parameters —
Returns
params is an optional dict:| Key | Type | Description |
|---|---|---|
limit | int | Number of results to return. Default: 50, max: 100. |
offset | int | Pagination offset. Default: 0. |
time_frame | str | '1H', '4H', '1D', '3D', '7D', '30D'. Default: '30D'. |
sort_by | str | 'pnl', 'roi', 'win_rate', 'market_count'. Default: 'pnl'. |
tag | str | Filter by market tag, e.g. 'crypto', 'sports'. |
min_win_rate | float | Minimum win rate (0–100). |
max_win_rate | float | Maximum win rate (0–100). |
min_roi | float | Minimum ROI percentage. |
max_roi | float | Maximum ROI percentage. |
last_active_hours | int | Only include traders active in the last N hours. |
min_market_count | int | Minimum number of markets traded. |
max_market_count | int | Maximum number of markets traded. |
dict.get_trader_profile(address)
get_trader_profile(address)
Get a trader’s detailed profile including tags, stats, and metadata.
Returns
| Parameter | Type | Description |
|---|---|---|
address | str | The EVM wallet address of the trader. |
dict.get_trader_markets(address, params)
get_trader_markets(address, params)
Retrieve a trader’s trading history aggregated by market.
Returns
| Parameter | Type | Description |
|---|---|---|
address | str | The EVM wallet address of the trader. |
limit | int | Number of markets to return. Default: 20, max: 100. |
offset | int | Pagination offset. Default: 0. |
is_active | bool | Filter by active (unresolved) markets only. |
dict.get_trader_market_orders(address, market_id)
get_trader_market_orders(address, market_id)
Retrieve a specific trader’s order history within a specific market.
Returns
| Parameter | Type | Description |
|---|---|---|
address | str | The EVM wallet address of the trader. |
market_id | str | int | The specific market ID. |
dict.get_market_detail(market_id)
get_market_detail(market_id)
Retrieve detailed information about a specific market.
Returns
| Parameter | Type | Description |
|---|---|---|
market_id | str | int | The unique numeric ID of the market. |
dict.stream_orders(params) — generator
stream_orders(params) — generator
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.Parameters —
Yields
params is an optional dict:| Key | Type | Description |
|---|---|---|
traders | str | Comma-separated list of trader addresses to follow. |
tags | str | Comma-separated list of market tags to filter by. |
series | str | Comma-separated list of series slugs. |
min_usdc | float | Minimum USDC trade size. |
max_usdc | float | Maximum USDC trade size. |
min_shares | float | Minimum shares amount. |
max_shares | float | Maximum shares amount. |
min_price | float | Minimum price (0–100). |
max_price | float | Maximum price (0–100). |
format | str | Set to 'json' for structured JSON. Omit for compact array format (recommended). |
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:
format='json' in the params dict to stream_orders — the raw response is yielded directly without calling the parser.