Skip to main content
Get up and running with the Polymarket API in minutes — fetch market data and place your first order.
1

Fetch a Market

All data endpoints are public — no API key or authentication needed. Use the markets endpoint to find a market and get its token IDs:
curl "https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=1"
Save a token ID from clobTokenIds — you’ll need it to place an order. The first ID is the Yes token, the second is the No token. See Fetching Markets for more strategies like fetching by slug, tag, or event.
2

Install the SDK

npm install @polymarket/clob-client ethers@5
3

Set Up Your Client

Derive API credentials and initialize the trading client:
import { ClobClient } from "@polymarket/clob-client";
import { Wallet } from "ethers"; // v5.8.0

const HOST = "https://clob.polymarket.com";
const CHAIN_ID = 137; // Polygon mainnet
const signer = new Wallet(process.env.PRIVATE_KEY);

// Derive API credentials (L1 → L2 auth)
const tempClient = new ClobClient(HOST, CHAIN_ID, signer);
const apiCreds = await tempClient.createOrDeriveApiKey();

// Initialize trading client
const client = new ClobClient(
  HOST,
  CHAIN_ID,
  signer,
  apiCreds,
  0, // Signature type: 0 = EOA
  signer.address, // Funder address
);
This example uses an EOA wallet (signature type 0) — your wallet pays its own gas. Proxy wallet users (types 1 and 2) can use Polymarket’s gasless relayer instead. See Authentication for details on signature types.
Before trading, your funder address needs USDC.e (for buying outcome tokens) and POL (for gas, if using EOA type 0).
4

Place an Order

Use the token_id from Step 1 to place a limit order:
import { Side, OrderType } from "@polymarket/clob-client";

// Fetch market details to get tick size and neg risk
const market = await client.getMarket("YOUR_CONDITION_ID");
const tickSize = String(market.minimum_tick_size);   // e.g., "0.01"
const negRisk = market.neg_risk;             // e.g., false

const response = await client.createAndPostOrder(
  {
    tokenID: "YOUR_TOKEN_ID", // From Step 1
    price: 0.50,
    size: 10,
    side: Side.BUY,
    orderType: OrderType.GTC,
  },
  {
    tickSize,
    negRisk,
  },
);

console.log("Order ID:", response.orderID);
console.log("Status:", response.status);

Next Steps