Node.js
Install, connect and receive fills in TypeScript.
pmwallets-node on GitHub, pmwallets on npm. Node.js ≥ 20, TypeScript types included.
shell
npm install pmwallets
typescript
import { PmwClient, FillStream, FileStateStore, verifyWebhook } from 'pmwallets'; const pmw = new PmwClient({ apiKey: process.env.PMW_API_KEY! }); // who is making money on Polymarket, and how const board = await pmw.leaderboard({ minWinLo: 0.55, minEligible: 30, style: 'taker', status: 'active', limit: 50 }); // only wallets whose address unlocks for free or in the cheapest paid band (0 = free … 5; the ladder is board.pricing.bands) const cheap = await pmw.leaderboard({ bands: [0, 1], minWinLo: 0.55 }); // follow one (billed per entity per hour; 402 = balance too low, 409 = dormant) await pmw.subscribe({ entityId: board.rows[0].entityId, channels: ['ws'] }); // every fill of every entity you follow const stream = new FillStream({ client: pmw, store: new FileStateStore('./stream.json'), // a restart resumes from the last saved cursor onFill: async (fill, { source }) => console.log(source, fill.side, fill.price, fill.tokenId), onEvent: (e) => e.type === 'replaced' && console.warn('another connection took the stream'), }); await stream.start();
| What it does | |
|---|---|
PmwClient | every REST call — see the method list |
FillStream | WebSocket with reconnect and keep-alive; gap detection and replay; de-duplication; persisted cursor |
verifyWebhook(rawBody, signature, secret) | checks x-pmw-signature (HMAC-SHA256 of the raw body) |