PolyEdge Python SDK
Official Python SDK for PolyEdge — Ultra-Low-Latency Polymarket Mempool Trade Streaming & Real-Time On-Chain Analytics API.
Engineered for Polymarket copy-trading bots, professional traders, and prediction market builders. Capture pending trades pre-block and track smart money with institutional-grade on-chain analytics.
Key Features
- 4 First-Class Namespaces: Aligned with OpenAPI 3.1:
client.streams: Real-time SSE trade streaming, sessions & filter management.client.analytics: Polymarket on-chain trade attribution, trader leaderboards, market settlement audit.client.account: User profile, API keys, request telemetry, and ledger.client.subscription: Pricing tier catalog, upgrade quotes, and promo codes.
- Asynchronous SSE Stream Engine:
- 45s Keep-Alive Watchdog: Native
httpxread-timeout detection automatically cleans up dead socket half-open connections. - Automatic Resume with
Last-Event-ID: Seamlessly retrieves buffered trades on reconnection. - Fail-Fast Policy: Immediate non-retry termination on fatal HTTP 401/403/404 errors.
- Pythonic Async Iterator: Streamlined
async for tx in stream.subscribe():interface.
- 45s Keep-Alive Watchdog: Native
- Pre-Block Polymarket Trade Streaming: Peered with 100+ Polygon nodes to capture pending Polymarket trades pre-block. The World's Fastest — verify yourself.
Installation
pip install polyedge
Quick Start
1. Initialize Client
import os
from polyedge import PolyEdgeClient
client = PolyEdgeClient(api_key=os.environ.get("POLYEDGE_API_KEY", "your_polyedge_api_key"))
2. Real-Time Mempool Trade Stream (SSE)
import asyncio
from polyedge import PolyEdgeClient
async def main():
client = PolyEdgeClient(api_key="your_polyedge_api_key")
stream = client.streams.connect("your_stream_id", heartbeat_timeout=45.0)
# Optional heartbeat listener
stream.on_heartbeat(lambda: print("💓 Server heartbeat received"))
async for tx in stream.subscribe():
tx_hash = tx.get("tx_hash", "")[:18]
question = tx.get("market", {}).get("question", "")
taker = tx.get("taker", {})
outcome = taker.get("outcome")
side = taker.get("side")
shares = taker.get("shares")
makers_count = len(tx.get("makers", []))
print(f"⚡ [Live Trade] Tx: {tx_hash}...")
print(f" Market: \"{question}\"")
print(f" Taker: {outcome} ({side}) | Shares: {shares}")
print(f" Matched Makers: {makers_count} orders")
if __name__ == "__main__":
asyncio.run(main())
3. Analytics: Leaderboard & Trader Dossier
# Leaderboard
leaderboard = client.analytics.get_leaderboard(limit=5)
print(f"Total active traders tracked: {leaderboard.get('total_count')}")
for i, t in enumerate(leaderboard.get("traders", [])):
addr = t.get("profile", {}).get("address")
name = t.get("profile", {}).get("name") or "Anonymous"
pnl_usd = (t.get("total_pnl", 0)) / 1e6
print(f"#{i + 1} {addr} ({name}) - Realized PnL: ${pnl_usd:,.2f}")
# Deep Trader Profile
profile = client.analytics.get_trader("0x51698a47f840a242abc2ca0351371c7ffac41842")
print(f"Taker Rebate Tier: {profile.get('taker_tier_name')}")
4. Account Profile & Telemetry
# Account info
profile = client.account.get_profile()
print(f"Email: {profile.get('email')}, Tier: {profile.get('tier')}")
# Daily telemetry
telemetry = client.account.get_telemetry()
print(f"Total API calls today: {telemetry.get('total_requests')}")
Complete API Service Reference (28 Methods)
1. Streams Service (client.streams)
| Method | HTTP | Description |
|---|---|---|
connect(stream_id, heartbeat_timeout) |
GET /streams/{id} (SSE) |
Connect to ultra-low-latency real-time SSE mempool trade stream |
list() |
GET /streams |
List all configured data streams |
create(req) |
POST /streams |
Provision a new targeted filter stream (tags, addresses, series) |
get(id) |
GET /streams/{id} |
Get stream metadata and configuration by ID |
update_metadata(id, req) |
PUT /streams/{id}/meta |
Update stream name and description |
update_subscription(id, req) |
PUT /streams/{id}/subscription |
Hot-reload market filters (addresses, tags, series) on active stream |
delete(id) |
DELETE /streams/{id} |
Delete stream by ID |
get_active_sessions() |
GET /sessions |
List all active live SSE connections across streams |
get_session_history(limit, offset) |
GET /sessions/history |
Query historical SSE connection logs and durations |
2. Analytics Service (client.analytics)
| Method | HTTP | Description |
|---|---|---|
get_leaderboard(limit, offset) |
GET /v2/analytics/leaderboard |
Top profitable traders ranked by realized PnL, volume, and ROI |
get_trader(address) |
GET /v2/traders/{address} |
Comprehensive trader intelligence profile, taker tier, and top tags |
get_trader_hourly_stats(address) |
GET /v2/traders/{address}/hourly_stats |
24-hour hourly trading PnL and volume breakdown |
get_trader_markets(address, limit, offset) |
GET /v2/traders/{address}/markets |
Historical market positions and settled outcomes by trader |
get_trader_market_orders(addr, id, limit, offset) |
GET /v2/traders/{address}/markets/{id}/orders |
Order fill details for a specific trader in a specific market |
get_market(id) |
GET /v2/markets/{id} |
Prediction market detail, top 20 earners, and volume attribution |
get_deposits(limit, offset) |
GET /v2/analytics/deposits |
60-day aggregated trader deposit summaries (>= 100 pUSD) |
3. Account Service (client.account)
| Method | HTTP | Description |
|---|---|---|
get_profile() |
GET /v2/user/me |
Current user profile, active tier, and deposit balance |
list_keys() |
GET /v2/user/keys |
List all active API keys and statuses |
create_key(req) |
POST /v2/user/keys |
Generate a new API key with custom name |
update_key(key, req) |
PATCH /v2/user/keys/{key} |
Enable, disable, or rename an API key |
delete_key(key) |
DELETE /v2/user/keys/{key} |
Revoke and delete an API key |
get_ledger(limit, offset) |
GET /v2/user/ledger |
Balance ledger transaction records |
get_telemetry() |
GET /v2/user/telemetry |
Daily request count and per-endpoint usage telemetry |
withdraw(req) |
POST /v2/user/withdraw |
Request balance withdrawal |
4. Subscription Service (client.subscription)
| Method | HTTP | Description |
|---|---|---|
list_tiers() |
GET /v2/tiers |
Public tier catalog, feature allowances, and pricing specifications |
get_quote(req) |
POST /v2/user/subscribe/quote |
Calculate quote for plan upgrade or billing cycle change |
subscribe(req) |
POST /v2/user/subscribe |
Purchase or upgrade tier subscription |
validate_promo_code(req) |
POST /v2/user/promo-codes/validate |
Validate promotional discount code |
License
MIT © 2026 PolyEdge Labs
Metadata
Release files for polyedge 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| polyedge-1.0.0.tar.gz | 17.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| polyedge-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.4 kB
Release files / polyedge-1.0.0.tar.gz
| Download URL | polyedge-1.0.0.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eaeef425cb11771e322d95b6f4cd4b6dea4bfb0e0903b39d7e9c1d71182de9c2
|
|
BLAKE2b-256 checksum How to use checksums |
f8a0f9978071437c83b0dffb835547ee809eab92c9a49c1a732d308c203dd155
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.2
|
Release files / polyedge-1.0.0-py3-none-any.whl
| Download URL | polyedge-1.0.0-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11944de6db76f1bf71106c0330785c6fe504aa63133bf57b9dc217c794867e4d
|
|
BLAKE2b-256 checksum How to use checksums |
1273231cae408ebca117022fcb2826c171ea2bc5a5eba3a653acd988325155e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.2
|