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:
+118
-154
@@ -2,195 +2,159 @@
|
||||
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
|
||||
> Use this file to discover all available pages before exploring further.
|
||||
|
||||
# Fetching Market Data
|
||||
# Fetching Markets
|
||||
|
||||
> Fetch Polymarket data in minutes with no authentication required
|
||||
|
||||
Get market data with zero setup. No API key, no authentication, no wallet required.
|
||||
|
||||
***
|
||||
|
||||
## Understanding the Data Model
|
||||
|
||||
Before fetching data, understand how Polymarket structures its markets:
|
||||
|
||||
<Steps>
|
||||
<Step title="Event">
|
||||
The top-level object representing a question like "Will X happen?"
|
||||
</Step>
|
||||
|
||||
<Step title="Market">
|
||||
Each event contains one or more markets. Each market is a specific tradable binary outcome.
|
||||
</Step>
|
||||
|
||||
<Step title="Outcomes & Prices">
|
||||
Markets have `outcomes` and `outcomePrices` arrays that map 1:1. These prices represent implied probabilities.
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
```json theme={null}
|
||||
{
|
||||
"outcomes": "[\"Yes\", \"No\"]",
|
||||
"outcomePrices": "[\"0.20\", \"0.80\"]"
|
||||
}
|
||||
// Index 0: "Yes" → 0.20 (20% probability)
|
||||
// Index 1: "No" → 0.80 (80% probability)
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## Fetch Active Events
|
||||
|
||||
List all currently active events on Polymarket:
|
||||
|
||||
```bash theme={null}
|
||||
curl "https://gamma-api.polymarket.com/events?active=true&closed=false&limit=5"
|
||||
```
|
||||
|
||||
<Accordion title="Example Response">
|
||||
```json theme={null}
|
||||
[
|
||||
{
|
||||
"id": "123456",
|
||||
"slug": "will-bitcoin-reach-100k-by-2025",
|
||||
"title": "Will Bitcoin reach $100k by 2025?",
|
||||
"active": true,
|
||||
"closed": false,
|
||||
"tags": [
|
||||
{ "id": "21", "label": "Crypto", "slug": "crypto" }
|
||||
],
|
||||
"markets": [
|
||||
{
|
||||
"id": "789",
|
||||
"question": "Will Bitcoin reach $100k by 2025?",
|
||||
"clobTokenIds": ["TOKEN_YES_ID", "TOKEN_NO_ID"],
|
||||
"outcomes": "[\"Yes\", \"No\"]",
|
||||
"outcomePrices": "[\"0.65\", \"0.35\"]"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
</Accordion>
|
||||
> Three strategies for discovering and querying markets
|
||||
|
||||
<Tip>
|
||||
Always use `active=true&closed=false` to filter for live, tradable events.
|
||||
Both the events and markets endpoints are paginated. See
|
||||
[pagination](#pagination) for details.
|
||||
</Tip>
|
||||
|
||||
***
|
||||
There are three main strategies for retrieving market data, each optimized for different use cases:
|
||||
|
||||
## Market Discovery Best Practices
|
||||
|
||||
### For Sports Events
|
||||
|
||||
Use the `/sports` endpoint to discover leagues, then query by `series_id`:
|
||||
|
||||
```bash theme={null}
|
||||
# Get all supported sports leagues
|
||||
curl "https://gamma-api.polymarket.com/sports"
|
||||
|
||||
# Get events for a specific league (e.g., NBA series_id=10345)
|
||||
curl "https://gamma-api.polymarket.com/events?series_id=10345&active=true&closed=false"
|
||||
|
||||
# Filter to just game bets (not futures) using tag_id=100639
|
||||
curl "https://gamma-api.polymarket.com/events?series_id=10345&tag_id=100639&active=true&closed=false&order=startTime&ascending=true"
|
||||
```
|
||||
|
||||
<Note>
|
||||
`/sports` only returns automated leagues. For others (UFC, Boxing, F1, Golf, Chess), use tag IDs via `/events?tag_id=<tag_id>`.
|
||||
</Note>
|
||||
|
||||
### For Non-Sports Topics
|
||||
|
||||
Use `/tags` to discover all available categories, then filter events:
|
||||
|
||||
```bash theme={null}
|
||||
# Get all available tags
|
||||
curl "https://gamma-api.polymarket.com/tags?limit=100"
|
||||
|
||||
# Query events by topic
|
||||
curl "https://gamma-api.polymarket.com/events?tag_id=2&active=true&closed=false"
|
||||
```
|
||||
|
||||
<Tip>
|
||||
Each event response includes a `tags` array, useful for discovering categories from live data and building your own tag mapping.
|
||||
</Tip>
|
||||
1. **By Slug** — Best for fetching specific individual markets or events
|
||||
2. **By Tags** — Ideal for filtering markets by category or sport
|
||||
3. **Via Events Endpoint** — Most efficient for retrieving all active markets
|
||||
|
||||
***
|
||||
|
||||
## Get Market Details
|
||||
## Fetch by Slug
|
||||
|
||||
Once you have an event, get details for a specific market using its ID or slug:
|
||||
**Use case:** When you need to retrieve a specific market or event that you already know about.
|
||||
|
||||
```bash theme={null}
|
||||
curl "https://gamma-api.polymarket.com/markets?slug=will-bitcoin-reach-100k-by-2025"
|
||||
Individual markets and events are best fetched using their unique slug identifier. The slug can be found directly in the Polymarket frontend URL.
|
||||
|
||||
### How to Extract the Slug
|
||||
|
||||
From any Polymarket URL, the slug is the path segment after `/event/`:
|
||||
|
||||
```
|
||||
https://polymarket.com/event/fed-decision-in-october
|
||||
↑
|
||||
Slug: fed-decision-in-october
|
||||
```
|
||||
|
||||
The response includes `clobTokenIds`, you'll need these to fetch prices and place orders.
|
||||
### Examples
|
||||
|
||||
```bash theme={null}
|
||||
# Fetch an event by slug (query parameter)
|
||||
curl "https://gamma-api.polymarket.com/events?slug=fed-decision-in-october"
|
||||
|
||||
# Or use the path endpoint
|
||||
curl "https://gamma-api.polymarket.com/events/slug/fed-decision-in-october"
|
||||
```
|
||||
|
||||
```bash theme={null}
|
||||
# Fetch a market by slug (query parameter)
|
||||
curl "https://gamma-api.polymarket.com/markets?slug=fed-decision-in-october"
|
||||
|
||||
# Or use the path endpoint
|
||||
curl "https://gamma-api.polymarket.com/markets/slug/fed-decision-in-october"
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## Get Current Price
|
||||
## Fetch by Tags
|
||||
|
||||
Query the CLOB for the current price of any token:
|
||||
**Use case:** When you want to filter markets by category, sport, or topic.
|
||||
|
||||
Tags provide a way to categorize and filter markets. You can discover available tags and then use them to filter your requests.
|
||||
|
||||
### Discover Available Tags
|
||||
|
||||
**General tags:** `GET /tags` (Gamma API)
|
||||
|
||||
**Sports tags and metadata:** `GET /sports` (Gamma API)
|
||||
|
||||
The `/sports` endpoint returns metadata for sports including tag IDs, images, resolution sources, and series information.
|
||||
|
||||
### Filter by Tag
|
||||
|
||||
Once you have tag IDs, use the `tag_id` parameter in both events and markets endpoints:
|
||||
|
||||
```bash theme={null}
|
||||
curl "https://clob.polymarket.com/price?token_id=YOUR_TOKEN_ID&side=buy"
|
||||
# Fetch events for a specific tag
|
||||
curl "https://gamma-api.polymarket.com/events?tag_id=100381&limit=10&active=true&closed=false"
|
||||
```
|
||||
|
||||
<Accordion title="Example Response">
|
||||
```json theme={null}
|
||||
{
|
||||
"price": "0.65"
|
||||
}
|
||||
```
|
||||
</Accordion>
|
||||
### Additional Tag Filtering
|
||||
|
||||
You can also:
|
||||
|
||||
* Use `related_tags=true` to include related tag markets
|
||||
* Exclude specific tags with `exclude_tag_id`
|
||||
|
||||
```bash theme={null}
|
||||
# Include related tags
|
||||
curl "https://gamma-api.polymarket.com/events?tag_id=100381&related_tags=true&active=true&closed=false"
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## Get Orderbook Depth
|
||||
## Fetch All Active Markets
|
||||
|
||||
See all bids and asks for a market:
|
||||
**Use case:** When you need to retrieve all available active markets, typically for broader analysis or market discovery.
|
||||
|
||||
The most efficient approach is to use the events endpoint with `active=true&closed=false`, as events contain their associated markets.
|
||||
|
||||
```bash theme={null}
|
||||
curl "https://clob.polymarket.com/book?token_id=YOUR_TOKEN_ID"
|
||||
curl "https://gamma-api.polymarket.com/events?active=true&closed=false&limit=100"
|
||||
```
|
||||
|
||||
<Accordion title="Example Response">
|
||||
```json theme={null}
|
||||
{
|
||||
"market": "0x...",
|
||||
"asset_id": "YOUR_TOKEN_ID",
|
||||
"bids": [
|
||||
{ "price": "0.64", "size": "500" },
|
||||
{ "price": "0.63", "size": "1200" }
|
||||
],
|
||||
"asks": [
|
||||
{ "price": "0.66", "size": "300" },
|
||||
{ "price": "0.67", "size": "800" }
|
||||
]
|
||||
}
|
||||
```
|
||||
</Accordion>
|
||||
### Key Parameters
|
||||
|
||||
| Parameter | Description |
|
||||
| ----------- | ---------------------------------------------------------------------------------------------------------------- |
|
||||
| `order` | Field to order by (`volume_24hr`, `volume`, `liquidity`, `start_date`, `end_date`, `competitive`, `closed_time`) |
|
||||
| `ascending` | Sort direction (`true` for ascending, `false` for descending). Default: `false` |
|
||||
| `active` | Filter by active status (`true` for live tradable events) |
|
||||
| `closed` | Filter by closed status |
|
||||
| `limit` | Results per page |
|
||||
| `offset` | Number of results to skip for pagination |
|
||||
|
||||
```bash theme={null}
|
||||
# Get the highest volume active events
|
||||
curl "https://gamma-api.polymarket.com/events?active=true&closed=false&order=volume_24hr&ascending=false&limit=100"
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## More Data APIs
|
||||
## Pagination
|
||||
|
||||
All list endpoints return paginated responses with `limit` and `offset` parameters:
|
||||
|
||||
```bash theme={null}
|
||||
# Page 1: First 50 results
|
||||
curl "https://gamma-api.polymarket.com/events?active=true&closed=false&limit=50&offset=0"
|
||||
|
||||
# Page 2: Next 50 results
|
||||
curl "https://gamma-api.polymarket.com/events?active=true&closed=false&limit=50&offset=50"
|
||||
|
||||
# Page 3: Next 50 results
|
||||
curl "https://gamma-api.polymarket.com/events?active=true&closed=false&limit=50&offset=100"
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **For individual markets:** Use the slug method for direct lookups
|
||||
2. **For category browsing:** Use tag filtering to reduce API calls
|
||||
3. **For complete market discovery:** Use the events endpoint with pagination
|
||||
4. **Always include `active=true&closed=false`** unless you specifically need historical data
|
||||
5. **Use the events endpoint** and work backwards — events contain their associated markets, reducing the number of API calls needed
|
||||
|
||||
***
|
||||
|
||||
## Next Steps
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Gamma API" icon="database" href="/developers/gamma-markets-api/overview">
|
||||
Deep dive into market discovery
|
||||
<Card title="API Reference" icon="code" href="/api-reference/introduction">
|
||||
Full endpoint documentation with parameters and response schemas.
|
||||
</Card>
|
||||
|
||||
<Card title="Data API" icon="table" href="/developers/misc-endpoints/data-api-get-positions">
|
||||
Positions, activity, and holders data
|
||||
</Card>
|
||||
|
||||
<Card title="WebSocket" icon="bolt" href="/developers/CLOB/websocket/wss-overview">
|
||||
Real-time orderbook updates
|
||||
</Card>
|
||||
|
||||
<Card title="RTDS" icon="signal-stream" href="/developers/RTDS/RTDS-overview">
|
||||
Real-time data streaming service
|
||||
<Card title="Subgraph" icon="share-nodes" href="/market-data/subgraph">
|
||||
Query onchain data directly from the Polymarket subgraph.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
Reference in New Issue
Block a user