API & Developers

Polymarket Historical Data API JavaScript Guide

Use JavaScript or Node.js to query Polymarket historical data, market snapshots, and full order book depth from PolyHistorical.

Polymarket historical data API JavaScript searches usually come from builders wiring market history into dashboards, bots, serverless jobs, or Node.js research scripts. PolyHistorical lets JavaScript clients query historical Polymarket snapshots without scraping live pages.

Node.js Fetch Example

const API_KEY = "YOUR_API_KEY";
const BASE_URL = "https://api.polyhistorical.com/v1";

async function getJson(path) {
  const response = await fetch(BASE_URL + path, {
    headers: { "X-API-Key": API_KEY },
  });
  if (!response.ok) throw new Error("Request failed: " + response.status);
  return response.json();
}

const markets = await getJson("/markets?coin=BTC&market_type=5m&resolved=true&limit=10");
const slug = markets.markets[0].slug;
const snapshots = await getJson(
  "/markets/" + slug + "/snapshots?include_orderbook=true&limit=1000"
);

Best JavaScript Fits

  • Backtest dashboards that stream resolved market snapshots into charts.
  • Trading bot validation jobs that compare live signals with historical outcomes.
  • Developer tools that need market discovery, snapshots, and order book depth in one API flow.
  • LLM or agent workflows that need repeatable JSON data instead of browser-only state.

Data to Store

Field groupWhy it matters
Market metadataCoin, timeframe, slug, resolution, and lifecycle timestamps.
Snapshot pricesUP and DOWN probabilities at each historical timestamp.
Order book levelsBid and ask ladders for execution-aware fills.
Reference contextCrypto reference prices for signal and latency studies.

Related Resources

Core Polymarket Data Resources