Skip to main content

pmwallets — Python SDK for PMWallets

PyPI License: MIT Discord

Official Python client for PMWallets: the Polymarket smart-money leaderboard computed from the Polygon chain, and the real-time fills of the Polymarket wallets you follow — delivered in order, exactly once, with every gap replayed.

中文说明 · Node.js SDK: pmwallets-node · Ready-to-run copy-trading bot built on it: polymarket-copy-trading-bot-python

Install

pip install pmwallets     # Python ≥ 3.10

Create an API key on pmwallets.com/keys.

Signals and radar (Pro and Max)

entries = client.signals(category="sports")["entries"]
big = client.radar(minUsd=25000, smart=True)
client.save_signal_rule("signal", {"enabled": True, "scope": "official", "minWallets": 3, "windowMin": 30, "minUsd": 5000, "channels": ["ws", "webhook"]})

For live alerts use SignalStream(client, on_alert).start(), or pmwallets alerts on the command line. Amounts keep two significant figures, times the minute, and traders are named by handle.

Usage

import asyncio
from pmwallets import AsyncClient, Client, FillStream, FileStateStore

# synchronous REST
with Client(api_key="pmw_...") as pmw:
    board = pmw.leaderboard(minWinLo=0.55, minEligible=30, style="taker", status="active", limit=50)
    cheap = pmw.leaderboard(bands=[0, 1], minWinLo=0.55)   # address unlocks free or in the $1 band (0 = free ... 5)
    pmw.subscribe(board["rows"][0]["entityId"], channels=["ws"])   # billed per entity per hour

# every fill of every entity you follow
async def main():
    async with AsyncClient(api_key="pmw_...") as pmw:
        stream = FillStream(
            client=pmw,
            store=FileStateStore("stream.json"),     # a restart resumes exactly where it stopped
            on_fill=lambda fill, meta: print(meta.source, fill["side"], fill["price"], fill["tokenId"]),
            on_event=lambda e: e["type"] == "fatal" and print(e["error"]),   # e.g. another bot already holds the stream
            # takeover=True,   # replace whichever API client holds this account's stream (it stops with "replaced")
        )
        await stream.run()

asyncio.run(main())

What is in it

Client / AsyncClient leaderboard, entities, address unlocks (balance or plan), your unlocked addresses (my_addresses), plans (quote, buy_plan from the balance) and balance, invites, subscriptions, webhook status and deliveries, fills replay (fills, fills_since), trade-history exports
FillStream asyncio WebSocket with reconnect and keep-alive; detects missed frames by session/seq and replays them from the last fill delivered; de-duplicates by eventId; anchors behind the chain head on first start; persisted cursor
verify_webhook(raw_body, signature, secret) checks x-pmw-signature (HMAC-SHA256 of the raw body)

One stream per account:

  • An API-key connection takes priority over the pmwallets.com feed page (the page never takes the stream from it).
  • Between two API connections the first one keeps the stream. A second one — another key of the same account, or the same bot started twice — is refused: blocked, then fatal, and the stream stops. Pass takeover=True to replace the holder instead; the holder gets replaced, then fatal, and stops (it does not fight back).
  • A FillStream identifies itself with a random client_id, so its own reconnects after a network drop replace its own dead connection without needing takeover.
  • When the server restarts it closes the socket with 1012; the stream reconnects at once (event restarting) and replays anything it missed.

HTTPS_PROXY is honoured.

PMWallets' servers are in the United Kingdom. A consumer that also trades on Polymarket should run from Ireland (AWS eu-west-1): Polymarket does not accept API orders from the UK, the US and several EU countries.

AI agents: command line and MCP

The package installs a pmwallets command that prints JSON — for scripts, and for AI agents (Claude Code, Codex, Gemini CLI, Cursor, WorkBuddy, …) that act on the fills of the traders you follow.

export PMW_API_KEY=pmw_…
pmwallets leaderboard --minWinLo 0.55 --category politics --limit 20
pmwallets subscribe <handle>          # billed per hour
pmwallets new-fills                   # fills since the previous call, each once (poll it)
pmwallets watch                       # live: one JSON line per fill, with its market and decimal amounts
pmwallets watch --batch-sec 30 --exec 'claude -p "Fills from traders I follow are on stdin. …"'
pmwallets mcp                         # the same as MCP tools
pmwallets skill                       # the guide to give your agent (SKILL.md)
  • watch --exec runs the command once per batch, the fills on its stdin as JSON lines (and in $PMW_BATCH_FILE); fills that arrive while it runs make the next batch. A batch is handed over at most once: one whose command fails, times out or is interrupted is kept in pmw-watch/failed/ and never re-run — the agent may already have placed an order. Restarts resume from where the stream stopped.
  • To trade, give the agent pmwallets-copytrade: order buy <tokenId> --usdc 5 --key <eventId> (the same key never orders twice), market, balance, positions.
  • Platforms without a shell (Dify, Coze, n8n, GPT Actions): import openapi.json.
  • HTTPS_PROXY / NO_PROXY are honoured by the command line.

MCP config (Claude Desktop, Cursor, Windsurf, WorkBuddy, …):

{
  "mcpServers": {
    "pmwallets": {
      "command": "uvx",
      "args": ["pmwallets", "mcp"],
      "env": { "PMW_API_KEY": "pmw_..." }
    }
  }
}
  • The same pieces are importable: Watcher, MarketLookup, serve_mcp / McpTool, pmwallets_tools.

Trade-history exports

A purchase is access to files: one zstd-compressed CSV per wallet per UTC day, downloadable at once and again later.

order = client.create_export(["0x…"], "2026-09-01", "2026-09-30")
for f in client.export_files(order["id"])["files"]:
    data = client.download_export_file(f["wallet"], f["day"])  # .csv.zst
    # pandas: pd.read_csv(io.BytesIO(data), compression="zstd")

export_file_url(wallet, day) returns the short-lived link instead; the API key is never sent to the storage host.

Resources

Guides

License

MIT

Metadata

Release files for pmwallets 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pmwallets 0.9.0
File Size Uploaded Provenance Actions
pmwallets-0.9.0.tar.gz 102.6 kB With provenance Details for pmwallets-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pmwallets 0.9.0
File Interpreter ABI Platform Actions
pmwallets-0.9.0-py3-none-any.whl Python 3 none any Details for pmwallets-0.9.0-py3-none-any.whl

Total release size: 151.7 kB

Release files / pmwallets-0.9.0.tar.gz

Download URL pmwallets-0.9.0.tar.gz
Size 102.6 kB
Tags Source
SHA-256 checksum
How to use checksums
238101590f7fd0ca01e86edcf0fdd9080421708f58fa59ca3bae0f4d695fcfc1
BLAKE2b-256 checksum
How to use checksums
c1060a4d1081f87b0343d481631953ba197601292c0a5b9ba4f3916b7ff4f7df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / pmwallets-0.9.0-py3-none-any.whl

Download URL pmwallets-0.9.0-py3-none-any.whl
Size 49.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1dc0c393fa025e0ebbf926a9292857ce325af2da1427356e7a54cc205bcab0f
BLAKE2b-256 checksum
How to use checksums
cf6be477f95a6011313b1eb42253b90aa2605a96747b24b63a7440f086c02195
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for pmwallets 0.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pmwallets-0.9.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page