Skip to main content
Get up and running with polymarket-data in minutes. This guide walks through installation, configuration, and your first live requests.
1

Install

npm install polymarket-data
# or
pnpm add polymarket-data
yarn add polymarket-data
The package ships as ESM with bundled TypeScript declarations.
2

Create a client

import { Polymarket } from "polymarket-data";

const client = new Polymarket();

Optional configuration

OptionDescriptionDefault
dataEndpointBase URL for the classic data API.https://data-api.polymarket.com
gammaEndpointBase URL for the gamma API.https://gamma-api.polymarket.com
fetchCustom Fetch implementation (for SSR/tests).globalThis.fetch
const client = new Polymarket({
  dataEndpoint: "https://custom-data.polymarket.com",
  gammaEndpoint: "https://custom-gamma.polymarket.com",
  fetch: myCustomFetch,
});
Mocking in tests — pass a stubbed fetch that returns predefined payloads. All methods pipe through the injected fetch before validation.
3

Verify connectivity

const status = await client.health();
console.log(status); // { data: "OK" }
If this call fails, verify network access and endpoint URLs. The SDK throws HttpError for API failures and Error("Network error: …") for connectivity issues.
4

Make your first requests

// Portfolio analytics
const positions = await client.data.core.getPositions({
  user: "0x56687bf447db6ffa42ffe2204a05edaa20f55839",
  limit: 10,
});

// Market discovery
const markets = await client.gamma.markets.listMarkets({
  closed: false,
  liquidity_num_min: 1000,
  limit: 5,
});
Use named imports for types:
import type { Position, Market } from "polymarket-data";