Skip to main content

Clean Python library for Polymarket data — events, markets, whale tracking, history, and live feed.

Project description

Polymwk

Clean, pip-installable Python API around Polymarket’s 3/4 MESSY public APIs: events and markets, user profiles and positions, leaderboards, tags, order books, and live feed wiring.

Python: 3.12+

For LLMs / agents: SKILLS.md

Deeper docs: Usage · Architecture · Development rules


Install

you can git clone or just pip install as a library:

uv add polymwk / pip install polymwk 

Examples

Events

Search events, then inspect a market: positions, prices, rules, and resolution.

from polymwk import *

# Fetch events (Gamma search-style query)
events = fetchEvents(query="bitcoin", limit=5, status="active")
first_market = events[0].markets[0]
displayEvents(events, tags="nvda", show_markets=True)

# REST order book for one outcome token
book = fetchOrderBook(first_market.yes_token_id, market_slug=first_market.slug)
displayOrderBook(book, event_slug=events[0].slug, market_question=first_market.question)

# Market top holders 
holders = fetchMarketTopHolders(first_market, event_slug=events[0].slug)
displayMarketTopHolders(holders)

# User Positions
users_positions = fetchMarketUsersPositions(first_market, event_slug=events[0].slug, limit=15)
displayMarketUsersPositions(users_positions)

# Event's Prices
price_chart = fetchEventPrices(events[0], interval="max")
displayMarketPrices(price_chart)

# Event/Market Rules
rules = fetchEventRules(events[0])
displayMarketRules(rules)

#Event/Market Resolution Info
resolution = fetchEventResolution(events[0])
displayMarketResolution(resolution)

# Recent fills / activity on a market
last_activity = fetchMarketLastActivity(first_market, event_slug=events[0].slug, limit=12)
displayMarketLastActivity(last_activity)

# Threaded comments on the event page
event_comments = fetchEventComments(events[0], limit=8)
displayEventComments(event_comments)

Users

Use a proxy wallet 0x… or a handle (reflex102 / @reflex102). Functions resolve handles via Gamma where needed.

from polymwk import *

# Example profile: https://polymarket.com/@reflex102
user = "0x61270a2fbd3b5d4ef8d2c23cb8b6fb4df3bfd154"

# User's Profile Info
session_user = fetchUserInfo(user)
displayUserInfo(session_user)

# User's Positions (open/closed)
open = fetchUserPositions(user, limit=50, status="active")
closed = fetchUserPositions(user, limit=200, status="closed")
displayUserPositions(open, status="active")
displayUserPositions(closed, status="closed")

# User's Activity (fills buys etc)
act = fetchUserActivity(user, limit=100, offset=0)
displayUserActivity(act)

# Limit/market buy sell orders
trades_taker = fetchUserTrades(user, limit=50, offset=0, taker_only=False)
trades_maker = fetchUserTrades(user, limit=50, offset=0, taker_only=True)
displayUserTrades(trades_taker)
displayUserTrades(trades_maker)

# User's Leaderboard Ranking
lb = fetchUserLeaderboardRank(user, metric="profit", window="all", include_cross_metric=True)
displayUserLeaderboardRank(lb)

# General Leaderboard for any category you wish
board = fetchUsersLeaderboard(timeframe="weekly", category="all", order_by="pnl", limit=25)
displayUsersLeaderboard(board)

Tags (site-style categories)

from polymwk import *

#i have some prebuilt tags for you to discover markets with them. feel free to change them
displayTags(fetchTags())

Tags as query keywords (configs.tags)

Use bundled keyword lists (e.g. BITCOIN) the same way you might type tags into the site search.

from polymwk import displayEvents, fetchEvents
from polymwk.configs.tags import BITCOIN

events = fetchEvents(query=BITCOIN, limit=50, status="active")
event = events[40]
first_market = event.markets[0]

displayEvents(events, tags="bitcoin", show_markets=True)

Series, single event, market, live order book

Uncomment and adapt when you want slug- or id-based fetches and the live ladder.

from polymwk import *

# series = fetchSeries(query="bitcoin", limit=50, status="active")
# displaySeries(series, tags="bitcoin")

# ev = fetchEvent("when-will-bitcoin-hit-150k")
# displayEvent(ev)

# m = fetchMarket(slug=ev.markets[0].slug)
# displayMarket(m, event_title=ev.title)

# s = fetchSerie(id="10016")
# displaySerie(s)

# Same ladder as displayOrderBook, redrawn on each WebSocket update (Ctrl+C to stop).
# displayLiveOrderBook(
#     first_market.yes_token_id,
#     market_slug=first_market.slug,
#     event_slug=ev.slug,
#     market_question=first_market.question,
# )

Feed (WebSocket order book) {NOT YET FULLY IMPLEMENTED....}

subscribeMarketOrderBook streams CLOB updates for one outcome token_id and blocks until the socket ends. For a full terminal ladder that redraws on each update, use displayLiveOrderBook (see the commented block under Series, single event, market, live order book).

from polymwk import subscribeMarketOrderBook

subscribeMarketOrderBook(
     token_id,
     market_slug="optional-slug",
     on_best_bid_ask=on_tick,
)

Tests

pip install pytest
pytest

CLI Support soon too!

polymwk runTests

(pyproject.toml also lists dev tools under [dependency-groups] for installers that support dependency groups, for example uv sync --group dev.)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polymwk-0.1.0.tar.gz (175.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polymwk-0.1.0-py3-none-any.whl (93.6 kB view details)

Uploaded Python 3

File details

Details for the file polymwk-0.1.0.tar.gz.

File metadata

  • Download URL: polymwk-0.1.0.tar.gz
  • Upload date:
  • Size: 175.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for polymwk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 926e8967ac5ad24ea6ca2952995cf25f62eb75c2f1ad995af2167c00e1cb27f0
MD5 3158f16b3a508248499a9a3f01e0acc6
BLAKE2b-256 7ec58317496b6ff49fc1ffa9f52d68f4df7ece1da7771087999ebbfffc80f38b

See more details on using hashes here.

File details

Details for the file polymwk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: polymwk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 93.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for polymwk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 392cbabe09ba4b25c99c6c85a5eb937edd86fd85b02587737f49e79cde228c09
MD5 e557dcbea2c4524d117240fdfe557ba4
BLAKE2b-256 85b4b9fd76764f80da5f3cd00299ce73ea5ec50b1a6983fa7f75a4a4c970dcd9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page