Small Node.js toolkit around Polymarket’s public APIs: pull a user’s activity history, browse it in a local web UI, or get Telegram pings when someone you follow opens a new BUY.
This repo is not affiliated with Polymarket. It uses their documented-style HTTP endpoints (data-api.polymarket.com, gamma-api.polymarket.com). Those APIs can change or rate-limit without notice—treat this as a convenience layer, not a guaranteed integration.
- Node.js 18+ (uses built-in
fetch) - npm (or any client that respects
package.jsonscripts)
git clone <your-fork-or-url>
cd polymarket-analyzer
npm installCopy .env.example to .env when you use the Telegram monitor (see below). The web UI and activity CLI do not require a .env file.
Starts a local Express server that serves the frontend and proxies Polymarket so the browser never hits CORS issues.
npm run dev
# or: npm start / npm run uiOpen http://localhost:3333 (or set PORT in the environment). Enter a Polymarket username (with or without @) or a proxy wallet address (0x…). The app resolves usernames via Gamma search, then loads activity, open positions, and closed positions from the Data API and groups everything by market.
Default port is 3333; override with PORT=8080 npm run dev (or add PORT to .env if you load it yourself).
Useful for backups, custom analysis, or piping into your own tools.
npm run activity -- --user someusername
npm run activity -- --address 0x25e28169faea17421fcd4cc361f6436d1e449a09
npm run activity -- --user someusername --out activity.json(npm run analyze is an alias for the same script.)
Pagination stops when Polymarket returns no more rows or when you hit their historical offset cap (the code aligns with the API’s “max historical activity offset” behavior—expect roughly a few thousand recent events, not an unlimited archive).
Polls recent activity for one or more profiles and sends a Telegram message for each new TRADE / BUY it hasn’t seen before. State is stored under cache/monitor_*.json so restarts don’t spam old trades.
- Create a bot with @BotFather, copy the token.
- Get your chat id (e.g. message @userinfobot or use the Telegram API as you prefer).
- Put them in
.env(see.env.example).
npm run monitor -- --user trader1
npm run monitor -- --users alice,bob,charlie
npm run monitor -- --address 0x...
npm run monitor -- --interval 120You can also set POLYMARKET_MONITOR_USER or POLYMARKET_MONITOR_USERS in .env instead of passing flags.
Note: On first run, the script seeds “seen” ids from the latest page of activity so you don’t get a burst of historical BUYs—only new buys after that appear as alerts.
| Script | What it runs |
|---|---|
npm run dev |
Local web UI + API proxy (server.ts) |
npm run activity / analyze |
CLI activity fetch (get-activity.ts) |
npm run monitor |
Telegram BUY monitor (monitor.ts) |
src/server.ts— Express app, staticpublic/,/api/resolve,/api/activitysrc/get-activity.ts— CLI activity exportsrc/monitor.ts— Telegram polling +cache/statepublic/index.html— Single-page UI (Chart.js from CDN)
Code: MIT License — see LICENSE in the repo root.
Use at your own risk. Prediction markets involve financial loss. This software does not provide trading or investment advice.
If you publish a fork, keep the disclaimer that you’re not Polymarket and that API behavior may change.