You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
frompolymarket_usimportPolymarketUSclient=PolymarketUS()
# Get events with paginationevents=client.events.list({"limit": 10, "offset": 0, "active": True})
next_page=client.events.list({"limit": 10, "offset": 10, "active": True})
# Get a specific eventevent=client.events.retrieve(123)
event_by_slug=client.events.retrieve_by_slug("super-bowl-2025")
# Get marketsmarkets=client.markets.list()
market=client.markets.retrieve_by_slug("btc-100k")
# Get order bookbook=client.markets.book("btc-100k")
# Get best bid/offerbbo=client.markets.bbo("btc-100k")
# Searchresults=client.search.query({"query": "bitcoin"})
# Series and sportsseries=client.series.list()
sports=client.sports.list()
Authenticated Endpoints (Trading)
importosfrompolymarket_usimportPolymarketUSclient=PolymarketUS(
key_id=os.environ["POLYMARKET_KEY_ID"],
secret_key=os.environ["POLYMARKET_SECRET_KEY"],
)
# Create an orderorder=client.orders.create({
"marketSlug": "btc-100k-2025",
"intent": "ORDER_INTENT_BUY_LONG",
"type": "ORDER_TYPE_LIMIT",
"price": {"value": "0.55", "currency": "USD"},
"quantity": 100,
"tif": "TIME_IN_FORCE_GOOD_TILL_CANCEL",
})
# Get open ordersopen_orders=client.orders.list()
# Cancel an orderclient.orders.cancel(order["id"], {"marketSlug": "btc-100k-2025"})
# Cancel all ordersclient.orders.cancel_all()
# Get positionspositions=client.portfolio.positions()
# Get activity historyactivities=client.portfolio.activities()
# Get account balancesbalances=client.account.balances()
client.close()
Note: WebSocket connections are async-only due to their event-driven nature.
Use asyncio.run() when working with the sync client, or use AsyncPolymarketUS directly.