API Integration

PolyMarks integrates with multiple external APIs.

Polymarket Gamma API (Markets)

Endpoint: https://gamma-api.polymarket.com/markets

Used For: Fetching market data (questions, odds, volume, liquidity)

Parameters:

  • limit - Number of markets to fetch (default: 100, max: 500)

  • closed - Filter closed markets (default: false)

  • active - Filter active markets (default: true)

Sample Request:

GET https://gamma-api.polymarket.com/markets?limit=100&closed=false&active=true

Response Format:

{
  "data": [
    {
      "id": "...",
      "question": "Will Trump win 2024?",
      "description": "...",
      "outcomes": ["Yes", "No"],
      "volume": 1234567.89,
      "liquidity": 98765.43,
      "end_date": "2024-11-05T00:00:00Z",
      "slug": "trump-wins-2024",
      ...
    }
  ]
}

Our Proxy: /api/markets

Polymarket Data API (Trades)

Endpoint: https://data-api.polymarket.com/trades

Used For: Fetching whale trades

Parameters:

  • limit - Number of trades (default: 50, max: 200)

  • offset - Pagination offset

  • filterType - Filter by type (CASH)

  • filterAmount - Minimum trade size (USD)

  • eventId - Filter by market slug

Sample Request:

Response Format:

Our Proxy: /api/trades

Helius RPC (Solana)

Endpoint: https://mainnet.helius-rpc.com/?api-key=YOUR_KEY

Used For: Future Solana wallet tracking features

Sample Request:

Currently: Not actively used, prepared for future features

CORS & Proxying

All external API calls go through Next.js API routes to avoid CORS:

Before (CORS Error):

After (Proxy):

Rate Limiting

Polymarket APIs:

  • No official rate limit published

  • We observed 429 errors when fetching whale data for 100+ markets simultaneously

  • Solution: Disabled parallel market-whale fetching, only fetch on detail pages

Best Practices:

  • Cache responses (60s for markets, 30s for trades)

  • Batch requests when possible

  • Use pagination (limit + offset)

Error Handling

Always return empty arrays/null instead of throwing to prevent UI crashes.

Last updated