@polyman/data
v0.1.0
Published
Polymarket Data API client — user positions, trade history, and portfolio data
Readme
@polyman/data
Polymarket Data API client — user positions, trade history, and portfolio data.
Base URL:
https://data-api.polymarket.com
Installation
npm install @polyman/dataUsage
import { DataClient } from '@polyman/data';
const client = new DataClient();
const wallet = '0xYourWalletAddress';
// Open positions
const positions = await client.getPositions({ user: wallet });
positions.forEach(p => {
console.log(`${p.title}: ${p.size} shares @ $${p.avgPrice}`);
console.log(`PnL: $${p.cashPnl} (${p.percentPnl.toFixed(2)}%)`);
});
// Trade history
const trades = await client.getActivity({ user: wallet, limit: 50 });
// Portfolio summary
const portfolio = await client.getPortfolioValue(wallet);
console.log(`Total value: $${portfolio.portfolioValue}`);
console.log(`Realized PnL: $${portfolio.realizedPnl}`);API Reference
DataClient
| Method | Description |
|---|---|
| getPositions(params) | Get open positions for a wallet |
| getActivity(params) | Get trade activity/history for a wallet |
| getPortfolioValue(user) | Get portfolio value summary |
| getPnlHistory(user, limit?) | Get P&L history |
GetPositionsParams
| Field | Type | Description |
|---|---|---|
| user | string | Wallet address (required) |
| sizeThreshold | number | Min position size filter |
| limit | number | Max results |
| offset | number | Pagination offset |
GetActivityParams
| Field | Type | Description |
|---|---|---|
| user | string | Wallet address (required) |
| limit | number | Max results |
| before | number | Unix timestamp upper bound |
| after | number | Unix timestamp lower bound |
License
ISC
