Enable AI agents to interact with Jupiter Prediction Market API for autonomous trading and portfolio management.
const { JupiterPrediction, parseEventsResponse, formatUsd } = require('./src');
const client = new JupiterPrediction();
const events = await client.list({ category: 'crypto', filter: 'trending', limit: 5 });
const parsed = parseEventsResponse(events);
console.log('Events:', parsed.data.map(e => e.title));
export JUPITER_API_KEY=your-api-key
Or use config file config/api-key.json.
| Category | Methods |
|---|---|
| ---------- | --------- |
| Events | list, search, getEvent, suggested |
| Markets | getMarket, orderbook |
| Orders | create, listOrders, status, cancelOrder |
| Positions | listPositions, getPosition, closePosition, closeAllPositions, claim |
| History | listHistory, getHistoryByPosition |
| Social | profile, pnlHistory, trades, leaderboards, follow/unfollow |
| Function | Description |
|---|---|
| ---------- | ------------- |
microUsdToUsd(microUsd) | Convert micro USD to USD |
formatUsd(microUsd, decimals) | Format as currency string |
calculateProbability(yesPrice) | Implied probability (%) |
parseEventsResponse(response) | Parse event data |
parseMarketResponse(market) | Parse market data |
parsePositionsResponse(response) | Parse position data |
filterClaimable(positions) | Filter claimable positions |
filterOpen(positions) | Filter open positions |
aggregatePnL(positions) | Calculate total P&L |
Run from project root:
# Scan markets by criteria
node scripts/scan-markets.js --crypto --limit=10 --min-volume=10000
# Find mispriced opportunities
node scripts/find-opportunities.js --threshold=20 --min-volume=50000
# Monitor portfolio
node scripts/monitor-portfolio.js <wallet-address>
# Auto-claim winnings
node scripts/auto-claim.js <wallet-address> [--dry-run] [--min=1]
# Portfolio health check
node scripts/portfolio-health.js <wallet-address>
The bundled scripts provide complete autonomous agent workflows:
See src/ for available endpoints and utilities:
src/client.js - Main API client classsrc/index.js - Exports and utility functionssrc/endpoints/ - Individual endpoint modulessrc/utils/ - Helper functions (parser, prices, errors)Client methods are documented in code comments. Main classes:
JupiterPrediction - Main client (src/client.js)Verify syntax:
node --check src/index.js
node --check src/client.js
Run a script (requires JUPITER_API_KEY):
export JUPITER_API_KEY=your-key
node scripts/scan-markets.js --crypto --limit=5
MIT
共 1 个版本