Skip to content

bensaru/polymarket-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polymarket Analyzer

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.

What you need

  • Node.js 18+ (uses built-in fetch)
  • npm (or any client that respects package.json scripts)

Setup

git clone <your-fork-or-url>
cd polymarket-analyzer
npm install

Copy .env.example to .env when you use the Telegram monitor (see below). The web UI and activity CLI do not require a .env file.

Web UI (activity + PnL-style rollups)

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 ui

Open 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).

CLI: dump raw activity to JSON

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).

Telegram: BUY alerts

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.

  1. Create a bot with @BotFather, copy the token.
  2. Get your chat id (e.g. message @userinfobot or use the Telegram API as you prefer).
  3. 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 120

You 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.

Scripts (summary)

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)

Project layout

  • src/server.ts — Express app, static public/, /api/resolve, /api/activity
  • src/get-activity.ts — CLI activity export
  • src/monitor.ts — Telegram polling + cache/ state
  • public/index.html — Single-page UI (Chart.js from CDN)

License / risk

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.

About

A powerful analytics tool for Polymarket prediction markets, track wallets, analyze trades, and uncover profitable patterns on-chain.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors