Update Polymarket documentation (2026-02-19)
- Added new documentation URLs from llms.txt index - Updated TARGET.md with 244 total documentation pages - Scraped new pages for trading, concepts, and API reference sections - Updated changelog and new index pages
This commit is contained in:
+202
-103
@@ -2,121 +2,220 @@
|
||||
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
|
||||
> Use this file to discover all available pages before exploring further.
|
||||
|
||||
# Developer Quickstart
|
||||
# Quickstart
|
||||
|
||||
> Get started building with Polymarket APIs
|
||||
> Fetch a market and place your first order
|
||||
|
||||
Polymarket provides a suite of APIs and SDKs for building prediction market applications. This guide will help you understand what's available and where to find it.
|
||||
Get up and running with the Polymarket API in minutes — fetch market data and place your first order.
|
||||
|
||||
<Steps>
|
||||
<Step title="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:
|
||||
|
||||
<Tabs>
|
||||
<Tab title="cURL">
|
||||
```bash theme={null}
|
||||
curl "https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=1"
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab title="TypeScript">
|
||||
```typescript theme={null}
|
||||
const response = await fetch(
|
||||
"https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=1"
|
||||
);
|
||||
const markets = await response.json();
|
||||
|
||||
const market = markets[0];
|
||||
console.log(market.question);
|
||||
console.log(market.clobTokenIds);
|
||||
// ["123456...", "789012..."] — [Yes token ID, No token ID]
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab title="Python">
|
||||
```python theme={null}
|
||||
import requests
|
||||
|
||||
response = requests.get(
|
||||
"https://gamma-api.polymarket.com/markets",
|
||||
params={"active": "true", "closed": "false", "limit": 1}
|
||||
)
|
||||
markets = response.json()
|
||||
|
||||
market = markets[0]
|
||||
print(market["question"])
|
||||
print(market["clobTokenIds"])
|
||||
# ["123456...", "789012..."] — [Yes token ID, No token ID]
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
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](/market-data/fetching-markets) for more strategies like fetching by slug, tag, or event.
|
||||
</Step>
|
||||
|
||||
<Step title="Install the SDK">
|
||||
<CodeGroup>
|
||||
```bash TypeScript theme={null}
|
||||
npm install @polymarket/clob-client ethers@5
|
||||
```
|
||||
|
||||
```bash Python theme={null}
|
||||
pip install py-clob-client
|
||||
```
|
||||
</CodeGroup>
|
||||
</Step>
|
||||
|
||||
<Step title="Set Up Your Client">
|
||||
Derive API credentials and initialize the trading client:
|
||||
|
||||
<Tabs>
|
||||
<Tab title="TypeScript">
|
||||
```typescript theme={null}
|
||||
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
|
||||
);
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab title="Python">
|
||||
```python theme={null}
|
||||
from py_clob_client.client import ClobClient
|
||||
import os
|
||||
|
||||
host = "https://clob.polymarket.com"
|
||||
chain_id = 137 # Polygon mainnet
|
||||
private_key = os.getenv("PRIVATE_KEY")
|
||||
|
||||
# Derive API credentials (L1 → L2 auth)
|
||||
temp_client = ClobClient(host, key=private_key, chain_id=chain_id)
|
||||
api_creds = temp_client.create_or_derive_api_creds()
|
||||
|
||||
# Initialize trading client
|
||||
client = ClobClient(
|
||||
host,
|
||||
key=private_key,
|
||||
chain_id=chain_id,
|
||||
creds=api_creds,
|
||||
signature_type=0, # Signature type: 0 = EOA
|
||||
funder="YOUR_WALLET_ADDRESS", # Funder address
|
||||
)
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Note>
|
||||
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](/api-reference/authentication) for
|
||||
details on signature types.
|
||||
</Note>
|
||||
|
||||
<Warning>
|
||||
Before trading, your funder address needs **USDC.e** (for buying outcome
|
||||
tokens) and **POL** (for gas, if using EOA type `0`).
|
||||
</Warning>
|
||||
</Step>
|
||||
|
||||
<Step title="Place an Order">
|
||||
Use the `token_id` from Step 1 to place a limit order:
|
||||
|
||||
<Tabs>
|
||||
<Tab title="TypeScript">
|
||||
```typescript theme={null}
|
||||
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);
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab title="Python">
|
||||
```python theme={null}
|
||||
from py_clob_client.clob_types import OrderArgs, OrderType
|
||||
from py_clob_client.order_builder.constants import BUY
|
||||
|
||||
# Fetch market details to get tick size and neg risk
|
||||
market = client.get_market("YOUR_CONDITION_ID")
|
||||
tick_size = str(market["minimum_tick_size"]) # e.g., "0.01"
|
||||
neg_risk = market["neg_risk"] # e.g., False
|
||||
|
||||
response = client.create_and_post_order(
|
||||
OrderArgs(
|
||||
token_id="YOUR_TOKEN_ID", # From Step 1
|
||||
price=0.50,
|
||||
size=10,
|
||||
side=BUY,
|
||||
order_type=OrderType.GTC,
|
||||
),
|
||||
options={
|
||||
"tick_size": tick_size,
|
||||
"neg_risk": neg_risk,
|
||||
},
|
||||
)
|
||||
|
||||
print("Order ID:", response["orderID"])
|
||||
print("Status:", response["status"])
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
***
|
||||
|
||||
## What Can You Build?
|
||||
|
||||
| If you want to... | Start here |
|
||||
| ----------------------------- | ------------------------------------------------------------------- |
|
||||
| Fetch markets & prices | [Fetching Market Data](/quickstart/fetching-data) |
|
||||
| Place orders for yourself | [Placing Your First Order](/quickstart/first-order) |
|
||||
| Build a trading app for users | [Builders Program Introduction](/developers/builders/builder-intro) |
|
||||
| Provide liquidity | [Market Makers](/developers/market-makers/introduction) |
|
||||
|
||||
***
|
||||
|
||||
## APIs at a Glance
|
||||
|
||||
### Markets & Data
|
||||
## Next Steps
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Gamma API" icon="database" href="/developers/gamma-markets-api/overview">
|
||||
**Market discovery & metadata**
|
||||
|
||||
Fetch events, markets, categories, and resolution data. This is where you discover what's tradeable.
|
||||
|
||||
`https://gamma-api.polymarket.com`
|
||||
<Card title="Authentication" icon="lock" href="/api-reference/authentication">
|
||||
Understand L1/L2 auth, signature types, and API credentials.
|
||||
</Card>
|
||||
|
||||
<Card title="CLOB API" icon="book" href="/developers/CLOB/introduction">
|
||||
**Prices, orderbooks & trading**
|
||||
|
||||
Get real-time prices, orderbook depth, and place orders. The core trading API.
|
||||
|
||||
`https://clob.polymarket.com`
|
||||
<Card title="Trading Quickstart" icon="bolt" href="/trading/quickstart">
|
||||
Detailed trading guide with order management and troubleshooting.
|
||||
</Card>
|
||||
|
||||
<Card title="Data API" icon="chart-bar" href="/developers/misc-endpoints/data-api-get-positions">
|
||||
**Positions, activity & history**
|
||||
|
||||
Query user positions, trade history, and portfolio data.
|
||||
|
||||
`https://data-api.polymarket.com`
|
||||
<Card title="Fetching Markets" icon="magnifying-glass" href="/market-data/fetching-markets">
|
||||
Strategies for discovering markets by slug, tag, or category.
|
||||
</Card>
|
||||
|
||||
<Card title="WebSocket" icon="bolt" href="/developers/CLOB/websocket/wss-overview">
|
||||
**Real-time updates**
|
||||
|
||||
Subscribe to orderbook changes, price updates, and order status.
|
||||
|
||||
`wss://ws-subscriptions-clob.polymarket.com`
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
### Additional Data Sources
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="RTDS" icon="signal-stream" href="/developers/RTDS/RTDS-overview">
|
||||
**Low-latency data stream**
|
||||
|
||||
Real-time crypto prices and comments. Optimized for market makers.
|
||||
</Card>
|
||||
|
||||
<Card title="Subgraph" icon="diagram-project" href="/developers/subgraph/overview">
|
||||
**Onchain queries**
|
||||
|
||||
Query blockchain state directly via GraphQL.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
### Trading Infrastructure
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="CTF Operations" icon="arrows-split-up-and-left" href="/developers/CTF/overview">
|
||||
**Token split/merge/redeem**
|
||||
|
||||
Convert between USDC and outcome tokens. Essential for inventory management.
|
||||
</Card>
|
||||
|
||||
<Card title="Relayer Client" icon="gas-pump" href="/developers/builders/relayer-client">
|
||||
**Gasless transactions**
|
||||
|
||||
Builders can offer gasfree transactions via Polymarket's relayer.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
***
|
||||
|
||||
## SDKs & Libraries
|
||||
|
||||
<Card title="CLOB Client (TypeScript)" icon="npm" href="https://github.com/Polymarket/clob-client">
|
||||
`npm install @polymarket/clob-client`
|
||||
</Card>
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="CLOB Client (Python)" icon="python" href="https://github.com/Polymarket/py-clob-client">
|
||||
`pip install py-clob-client`
|
||||
</Card>
|
||||
|
||||
<Card title="CLOB Client (Rust)" icon="rust" href="https://github.com/Polymarket/rs-clob-client">
|
||||
`cargo add polymarket-client-sdk`
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
For builders routing orders for users:
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Relayer Client" icon="bolt" href="https://github.com/Polymarket/builder-relayer-client">
|
||||
Gasless wallet operations
|
||||
</Card>
|
||||
|
||||
<Card title="Signing SDK" icon="key" href="https://github.com/Polymarket/builder-signing-sdk">
|
||||
Builder authentication headers
|
||||
<Card title="Core Concepts" icon="book" href="/concepts/markets-events">
|
||||
Understand markets, events, prices, and positions.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
Reference in New Issue
Block a user