Requirements
- Node.js 18 or higher
- npm
Installation
Install the dependency
The SDK uses
eventsource-client for SSE streaming with auto-reconnect and async iterator support.Copy the SDK files
Download
polyedge.js and parser_compact_tx.js from the PolyEdge examples repository and copy them into your project directory.Instantiation
ImportPolyEdgeClient and pass your API key. The base URL defaults to https://api.polyedge.dev/v1.
X-PolyEdge-Key header.
Methods
getLeaderboard(params)
getLeaderboard(params)
Retrieve the trader leaderboard, optionally filtered and sorted.Parameters — all optional:
Returns a
| Parameter | Type | Description |
|---|---|---|
limit | number | Number of results to return. Default: 50, max: 100. |
offset | number | Pagination offset. Default: 0. |
time_frame | string | '1H', '4H', '1D', '3D', '7D', '30D'. Default: '30D'. |
sort_by | string | 'pnl', 'roi', 'win_rate', 'market_count'. Default: 'pnl'. |
tag | string | Filter by market tag, e.g. 'crypto', 'sports'. |
min_win_rate | number | Minimum win rate (0–100). |
max_win_rate | number | Maximum win rate (0–100). |
min_roi | number | Minimum ROI percentage. |
max_roi | number | Maximum ROI percentage. |
last_active_hours | number | Only include traders active in the last N hours. |
min_market_count | number | Minimum number of markets traded. |
max_market_count | number | Maximum number of markets traded. |
Promise<Object>.getTraderProfile(address)
getTraderProfile(address)
Get a trader’s detailed profile including tags, stats, and metadata.
Returns a
| Parameter | Type | Description |
|---|---|---|
address | string | The EVM wallet address of the trader. |
Promise<Object>.getTraderMarkets(address, params)
getTraderMarkets(address, params)
Retrieve a trader’s trading history aggregated by market.
Returns a
| Parameter | Type | Description |
|---|---|---|
address | string | The EVM wallet address of the trader. |
limit | number | Number of markets to return. Default: 20, max: 100. |
offset | number | Pagination offset. Default: 0. |
is_active | boolean | Filter by active (unresolved) markets only. |
Promise<Object>.getTraderMarketOrders(address, marketId)
getTraderMarketOrders(address, marketId)
Retrieve a specific trader’s order history within a specific market.
Returns a
| Parameter | Type | Description |
|---|---|---|
address | string | The EVM wallet address of the trader. |
marketId | string | number | The specific market ID. |
Promise<Object>.getMarketDetail(marketId)
getMarketDetail(marketId)
Retrieve detailed information about a specific market.
Returns a
| Parameter | Type | Description |
|---|---|---|
marketId | string | number | The unique numeric ID of the market. |
Promise<Object>.streamOrders(params) — async generator
streamOrders(params) — async generator
Subscribe to live mempool orders via SSE. Returns an async generator that yields parsed order objects.Break out of the loop at any time — the underlying SSE connection is closed automatically in the generator’s
Returns
finally block.Parameters — all optional:| Parameter | Type | Description |
|---|---|---|
traders | string | Comma-separated list of trader addresses to follow. |
tags | string | Comma-separated list of market tags to filter by. |
series | string | Comma-separated list of series slugs. |
min_usdc | number | Minimum USDC trade size. |
max_usdc | number | Maximum USDC trade size. |
min_shares | number | Minimum shares amount. |
max_shares | number | Maximum shares amount. |
min_price | number | Minimum price (0–100). |
max_price | number | Maximum price (0–100). |
format | string | Set to 'json' for structured JSON. Omit for compact array format (recommended). |
AsyncGenerator<Object, void, unknown>.When
format is omitted, each yielded value is the output of parseCompactTx — a fully structured JavaScript object. See Compact format parsing below.Compact format parsing
By default,streamOrders receives events in a compact array format optimised for low bandwidth. The parser_compact_tx.js utility converts each raw array into a structured object before yielding it.
The parsed object has this shape:
format: 'json' to streamOrders — the raw response is yielded directly without calling the parser.