Requirements
- Node.js 18 or higher
- npm
Installation
1
Install the dependency
The SDK uses
eventsource-client for SSE streaming with auto-reconnect and async iterator support.2
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
Promise<Object>.getTraderProfile(address)
getTraderProfile(address)
Get a trader’s detailed profile including tags, stats, and metadata.
Returns a
Promise<Object>.getTraderMarkets(address, params)
getTraderMarkets(address, params)
Retrieve a trader’s trading history aggregated by market.
Returns a
Promise<Object>.getTraderMarketOrders(address, marketId)
getTraderMarketOrders(address, marketId)
Retrieve a specific trader’s order history within a specific market.
Returns a
Promise<Object>.getTraderHourlyStats(address, params)
getTraderHourlyStats(address, params)
Get hourly aggregated performance data for a specific trader.
Returns a
Promise<Object>.getMarketDetail(marketId)
getMarketDetail(marketId)
Retrieve detailed information about a specific market.
Returns a
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
finally block.Parameters — all optional:Returns
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.