refactor: 重构目录结构以支持 i18n

创建 'i18n' 目录以存放多语言内容。将所有现有的中文内容(文档、提示词、技能、README)移动到 'i18n/zh/' 中。添加了新的根 README 作为语言入口,并为英文('en')翻译创建了占位符结构。
This commit is contained in:
tukuaiai
2025-12-16 21:30:13 +08:00
parent 1b235161ec
commit 624ef8d5f9
199 changed files with 674 additions and 654 deletions
-233
View File
@@ -1,233 +0,0 @@
---
name: polymarket
description: Comprehensive Polymarket skill covering prediction markets, API, trading, market data, and real-time WebSocket data streaming. Build applications with Polymarket services, monitor live trades, and integrate market predictions.
---
# Polymarket Comprehensive Skill
Complete assistance with Polymarket development - covering the full platform (API, trading, market data) and the real-time data streaming client (WebSocket subscriptions for live market activity).
## When to Use This Skill
This skill should be triggered when:
**Platform & API:**
- Working with Polymarket prediction markets
- Using Polymarket API for market data
- Implementing trading strategies
- Building applications with Polymarket services
- Learning Polymarket best practices
**Real-Time Data Streaming:**
- Connecting to Polymarket's WebSocket service
- Building prediction market monitoring tools
- Processing live trades, orders, and market updates
- Monitoring market comments and social reactions
- Tracking RFQ (Request for Quote) activity
- Integrating crypto price feeds
## Quick Reference
### Real-Time Data Client Setup
**Installation:**
```bash
npm install @polymarket/real-time-data-client
```
**Basic Usage:**
```typescript
import { RealTimeDataClient } from "@polymarket/real-time-data-client";
const onMessage = (message: Message): void => {
console.log(message.topic, message.type, message.payload);
};
const onConnect = (client: RealTimeDataClient): void => {
client.subscribe({
subscriptions: [{
topic: "activity",
type: "trades"
}]
});
};
new RealTimeDataClient({ onMessage, onConnect }).connect();
```
### Supported WebSocket Topics
**1. Activity (`activity`)**
- `trades` - Completed trades
- `orders_matched` - Order matching events
- Filters: `{"event_slug":"string"}` OR `{"market_slug":"string"}`
**2. Comments (`comments`)**
- `comment_created`, `comment_removed`
- `reaction_created`, `reaction_removed`
- Filters: `{"parentEntityID":number,"parentEntityType":"Event"}`
**3. RFQ (`rfq`)**
- Request/Quote lifecycle events
- No filters, no auth required
**4. Crypto Prices (`crypto_prices`, `crypto_prices_chainlink`)**
- `update` - Real-time price feeds
- Filters: `{"symbol":"BTC"}` (optional)
**5. CLOB User (`clob_user`)** ⚠️ Requires Auth
- `order` - User's order updates
- `trade` - User's trade executions
**6. CLOB Market (`clob_market`)**
- `price_change` - Price movements
- `agg_orderbook` - Aggregated order book
- `last_trade_price` - Latest prices
- `market_created`, `market_resolved`
### Authentication for User Data
```typescript
client.subscribe({
subscriptions: [{
topic: "clob_user",
type: "*",
clob_auth: {
key: "your-api-key",
secret: "your-api-secret",
passphrase: "your-passphrase"
}
}]
});
```
### Common Use Cases
**Monitor Specific Market:**
```typescript
client.subscribe({
subscriptions: [{
topic: "activity",
type: "trades",
filters: `{"market_slug":"btc-above-100k-2024"}`
}]
});
```
**Track Multiple Markets:**
```typescript
client.subscribe({
subscriptions: [{
topic: "clob_market",
type: "price_change",
filters: `["100","101","102"]`
}]
});
```
**Monitor Event Comments:**
```typescript
client.subscribe({
subscriptions: [{
topic: "comments",
type: "*",
filters: `{"parentEntityID":12345,"parentEntityType":"Event"}`
}]
});
```
## Reference Files
This skill includes comprehensive documentation in `references/`:
**Platform Documentation:**
- **api.md** - Polymarket API documentation
- **getting_started.md** - Getting started guide
- **guides.md** - Development guides
- **learn.md** - Learning resources
- **trading.md** - Trading documentation
- **other.md** - Additional resources
**Real-Time Client:**
- **README.md** - WebSocket client API and examples
- **llms.md** - LLM integration guide
- **llms-full.md** - Complete LLM documentation
Use `view` to read specific reference files for detailed information.
## Key Features
**Platform Capabilities:**
✅ Prediction market creation and resolution
✅ Trading API (REST & WebSocket)
✅ Market data queries
✅ User portfolio management
✅ Event and market discovery
**Real-Time Streaming:**
✅ WebSocket-based persistent connections
✅ Topic-based subscriptions
✅ Dynamic subscription management
✅ Filter support for targeted data
✅ User authentication for private data
✅ TypeScript with full type safety
✅ Initial data dumps on connection
## Best Practices
### WebSocket Connection Management
- Use `onConnect` callback for subscriptions
- Implement reconnection logic for production
- Clean up with `disconnect()` when done
- Handle authentication errors gracefully
### Subscription Strategy
- Use wildcards (`"*"`) sparingly
- Apply filters to reduce data volume
- Unsubscribe from unused streams
- Process messages asynchronously
### Performance
- Consider batching high-frequency data
- Use filters to minimize client processing
- Validate message payloads before use
## Requirements
- **Node.js**: 14+ recommended
- **TypeScript**: Optional but recommended
- **Package Manager**: npm or yarn
## Resources
### Official Links
- **Polymarket Platform**: https://polymarket.com
- **Real-Time Client Repo**: https://github.com/Polymarket/real-time-data-client
- **API Documentation**: See references/api.md
### Working with This Skill
**For Beginners:**
Start with `getting_started.md` for foundational concepts.
**For API Integration:**
Use `api.md` and `trading.md` for REST API details.
**For Real-Time Data:**
Use `README.md` for WebSocket client implementation.
**For LLM Integration:**
Use `llms.md` and `llms-full.md` for AI/ML use cases.
## Notes
- Real-Time Client is TypeScript/JavaScript (not Python)
- Some WebSocket topics require authentication
- Use filters to manage message volume effectively
- All timestamps are Unix timestamps
- Market IDs are strings (e.g., "100", "101")
- Platform documentation covers both REST API and WebSocket usage
---
**This comprehensive skill combines Polymarket platform expertise with real-time data streaming capabilities!**
-396
View File
@@ -1,396 +0,0 @@
# Real time data client
This client provides a wrapper to connect to the `real-time-data-streaming` `WebSocket` service.
## How to use it
Here is a quick example about how to connect to the service and start receiving messages (you can find more in the folder `examples/`):
```typescript
import { RealTimeDataClient } from "../src/client";
import { Message } from "../src/model";
const onMessage = (message: Message): void => {
console.log(message.topic, message.type, message.payload);
};
const onConnect = (client: RealTimeDataClient): void => {
// Subscribe to a topic
client.subscribe({
subscriptions: [
{
topic: "comments",
type: "*", // "*"" can be used to connect to all the types of the topic
filters: `{"parentEntityID":100,"parentEntityType":"Event"}`, // empty means no filter
},
],
});
};
new RealTimeDataClient({ onMessage, onConnect }).connect();
```
## How to subscribe and unsubscribe from messages
Once the connection is stablished and you have a `client: RealTimeDataClient` object, you can `subscribe` and `unsubscribe` to many messages streamings using the same connection.
### Subscribe
Subscribe to 'trades' messages from the topic 'activity' and to the all comments messages.
```typescript
client.subscribe({
subscriptions: [
{
topic: "activity",
type: "trades",
},
],
});
client.subscribe({
subscriptions: [
{
topic: "comments",
type: "*", // "*"" can be used to connect to all the types of the topic
},
],
});
```
### Unsubscribe
Unsubscribe from the new trades messages of the topic 'activity'. If 'activity' has more messages types and I used '\*' to connect to all of them, this will only unsubscribe from the type 'trades'.
```typescript
client.subscribe({
subscriptions: [
{
topic: "activity",
type: "trades",
},
],
});
```
### Disconnect
The `client` object provides a method to disconnect from the `WebSocket` server:
```typescript
client.disconnect();
```
## Messages hierarchy
| Topic | Type | Auth | Filters (if it is empty the messages won't be filtered) | Schema | Subscription Handler |
| ------------------------- | ------------------ | -------- | --------------------------------------------------------------- | ----------------------------------- | ----------------------------------------------------------- |
| `activity` | `trades` | - | `{"event_slug":"string"}' OR '{"market_slug":"string"}` | [`Trade`](#trade) | |
| `activity` | `orders_matched` | - | `{"event_slug":"string"}' OR '{"market_slug":"string"}` | [`Trade`](#trade) | |
| `comments` | `comment_created` | - | `{"parentEntityID":number,"parentEntityType":"Event / Series"}` | [`Comment`](#comment) | |
| `comments` | `comment_removed` | - | `{"parentEntityID":number,"parentEntityType":"Event / Series"}` | [`Comment`](#comment) | |
| `comments` | `reaction_created` | - | `{"parentEntityID":number,"parentEntityType":"Event / Series"}` | [`Reaction`](#reaction) | |
| `comments` | `reaction_removed` | - | `{"parentEntityID":number,"parentEntityType":"Event / Series"}` | [`Reaction`](#reaction) | |
| `rfq` | `request_created` | - | - | [`Request`](#request) | |
| `rfq` | `request_edited` | - | - | [`Request`](#request) | |
| `rfq` | `request_canceled` | - | - | [`Request`](#request) | |
| `rfq` | `request_expired` | - | - | [`Request`](#request) | |
| `rfq` | `quote_created` | - | - | [`Quote`](#quote) | |
| `rfq` | `quote_edited` | - | - | [`Quote`](#quote) | |
| `rfq` | `quote_canceled` | - | - | [`Quote`](#quote) | |
| `rfq` | `quote_expired` | - | - | [`Quote`](#quote) | |
| `crypto_prices` | `update` | - | `{"symbol":string}` | [`CryptoPrice`](#cryptoprice) | [`CryptoPriceHistorical`](#initial-data-dump-on-connection) |
| `crypto_prices_chainlink` | `update` | - | `{"symbol":string}` | [`CryptoPrice`](#cryptoprice) | [`CryptoPriceHistorical`](#initial-data-dump-on-connection) |
| `clob_user` | `order` | ClobAuth | - | [`Order`](#order) | |
| `clob_user` | `trade` | ClobAuth | - | [`Trade`](#trade-1) | |
| `clob_market` | `price_change` | - | `["100","200",...]` (filters are mandatory on this one) | [`PriceChanges`](#pricechanges) | |
| `clob_market` | `agg_orderbook` | - | `["100","200",...]` | [`AggOrderbook`](#aggorderbook) | [`AggOrderbook`](#aggorderbook) |
| `clob_market` | `last_trade_price` | - | `["100","200",...]` | [`LastTradePrice`](#lasttradeprice) | |
| `clob_market` | `tick_size_change` | - | `["100","200",...]` | [`TickSizeChange`](#ticksizechange) | |
| `clob_market` | `market_created` | - | - | [`ClobMarket`](#clobmarket) | |
| `clob_market` | `market_resolved` | - | - | [`ClobMarket`](#clobmarket) | |
## Auth
### ClobAuth
```typescript
/**
* API key credentials for CLOB authentication.
*/
export interface ClobApiKeyCreds {
/** API key used for authentication */
key: string;
/** API secret associated with the key */
secret: string;
/** Passphrase required for authentication */
passphrase: string;
}
```
```typescript
client.subscribe({
subscriptions: [
{
topic: "clob_user",
type: "*",
clob_auth: {
key: "xxxxxx-xxxx-xxxxx-xxxx-xxxxxx",
secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
passphrase: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
},
},
],
});
```
## Message types
### Activity
#### Trade
| Name | Type | Description |
| ----------------- | ------- | -------------------------------------------------- |
| `asset` | string | ERC1155 token ID of conditional token being traded |
| `bio` | string | Bio of the user of the trade |
| `conditionId` | string | Id of market which is also the CTF condition ID |
| `eventSlug` | string | Slug of the event |
| `icon` | string | URL to the market icon image |
| `name` | string | Name of the user of the trade |
| `outcome` | string | Human readable outcome of the market |
| `outcomeIndex` | integer | Index of the outcome |
| `price` | float | Price of the trade |
| `profileImage` | string | URL to the user profile image |
| `proxyWallet` | string | Address of the user proxy wallet |
| `pseudonym` | string | Pseudonym of the user |
| `side` | string | Side of the trade (`BUY`/`SELL`) |
| `size` | integer | Size of the trade |
| `slug` | string | Slug of the market |
| `timestamp` | integer | Timestamp of the trade |
| `title` | string | Title of the event |
| `transactionHash` | string | Hash of the transaction |
### Comments
#### Comment
| Name | Type | Description |
| ------------------ | ------ | ------------------------------------------- |
| `id` | string | Unique identifier of comment |
| `body` | string | Content of the comment |
| `parentEntityType` | string | Type of the parent entity (Event or Series) |
| `parentEntityID` | number | ID of the parent entity |
| `parentCommentID` | string | ID of the parent comment |
| `userAddress` | string | Address of the user |
| `replyAddress` | string | Address of the reply user |
| `createdAt` | string | Creation timestamp |
| `updatedAt` | string | Last update timestamp |
#### Reaction
| Name | Type | Description |
| -------------- | ------ | ------------------------------ |
| `id` | string | Unique identifier of reaction |
| `commentID` | number | ID of the comment |
| `reactionType` | string | Type of the reaction |
| `icon` | string | Icon representing the reaction |
| `userAddress` | string | Address of the user |
| `createdAt` | string | Creation timestamp |
### RFQ
#### Request
| Name | Type | Description |
| -------------- | ------ | --------------------------------------------------------------- |
| `requestId` | string | Unique identifier for the request |
| `proxyAddress` | string | User proxy address |
| `market` | string | Id of market which is also the CTF condition ID |
| `token` | string | `ERC1155` token ID of conditional token being traded |
| `complement` | string | Complement `ERC1155` token ID of conditional token being traded |
| `state` | string | Current state of the request |
| `side` | string | Indicates buy or sell side |
| `sizeIn` | number | Input size of the request |
| `sizeOut` | number | Output size of the request |
| `price` | number | Price from in/out sizes |
| `expiry` | number | Expiry timestamp (UNIX format) |
#### Quote
| Name | Type | Description |
| -------------- | ------ | --------------------------------------------------------------- |
| `quoteId` | string | Unique identifier for the quote |
| `requestId` | string | Associated request identifier |
| `proxyAddress` | string | User proxy address |
| `token` | string | `ERC1155` token ID of conditional token being traded |
| `state` | string | Current state of the quote |
| `side` | string | Indicates buy or sell side |
| `sizeIn` | number | Input size of the quote |
| `sizeOut` | number | Output size of the quote |
| `sizeOut` | number | Output size of the request |
| `condition` | string | Id of market which is also the CTF condition ID |
| `complement` | string | Complement `ERC1155` token ID of conditional token being traded |
| `expiry` | number | Expiry timestamp (UNIX format) |
### CryptoPrice
| Name | Type | Description |
| ----------- | ------ | ---------------------------------------- |
| `symbol` | string | Symbol of the asset |
| `timestamp` | number | Timestamp in milliseconds for the update |
| `value` | number | Value at the time of update |
#### Filters
- `{"symbol":"btcusdt"}`
- `{"symbol":"ethusdt"}`
- `{"symbol":"xrpusdt"}`
- `{"symbol":"solusdt"}`
#### Initial data dump on connection
When the connection is stablished, if a `filter` is used, the server will dump an initial snapshoot of recent data
| Name | Type | Description |
| ------ | ------ | ---------------------------------------------------------------- |
| symbol | string | Symbol of the asset |
| data | array | Array of price data objects, each containing timestamp and value |
### CLOB User
#### Order
| Name | Type | Description |
| --------------- | ------------------ | --------------------------------------------------------- |
| `asset_id` | string | Order's `ERC1155` token ID of conditional token |
| `created_at` | string (timestamp) | Order's creation UNIX timestamp |
| `expiration` | string (timestamp) | Order's expiration UNIX timestamp |
| `id` | string | Unique order hash identifier |
| `maker_address` | string | Makers address (funder) |
| `market` | string | Condition ID or market identifier |
| `order_type` | string | Type of order: `GTC`, `GTD`, `FOK`, `FAK` |
| `original_size` | string | Original size of the order at placement |
| `outcome` | string | Order outcome: `YES` / `NO` |
| `owner` | string | UUID of the order owner |
| `price` | string | Order price (e.g., in decimals like `0.5`) |
| `side` | string | Side of the trade: `BUY` or `SELL` |
| `size_matched` | string | Amount of order that has been matched |
| `status` | string | Status of the order (e.g., `MATCHED`) |
| `type` | string | Type of update: `PLACEMENT`, `CANCELLATION`, `FILL`, etc. |
#### Trade
| Name | Type | Description |
| ------------------ | ------------------ | ----------------------------------------------------------------- |
| `asset_id` | string | `ERC1155` token ID of the conditional token involved in the trade |
| `fee_rate_bps` | string | Fee rate in basis points (bps) |
| `id` | string | Unique identifier for the match record |
| `last_update` | string (timestamp) | Last update timestamp (UNIX) |
| `maker_address` | string | Makers address |
| `maker_orders` | array | List of maker orders (see nested schema below) |
| `market` | string | Condition ID or market identifier |
| `match_time` | string (timestamp) | Match execution timestamp (UNIX) |
| `outcome` | string | Outcome of the market: `YES` / `NO` |
| `owner` | string | UUID of the taker (owner of the matched order) |
| `price` | string | Matched price (in decimal format, e.g., `0.5`) |
| `side` | string | Taker side of the trade: `BUY` or `SELL` |
| `size` | string | Total matched size |
| `status` | string | Status of the match: e.g., `MINED` |
| `taker_order_id` | string | ID of the taker's order |
| `transaction_hash` | string | Transaction hash where the match was settled |
##### `maker_orders`
| Name | Type | Description |
| ---------------- | ------ | ---------------------------------------------------------------- |
| `asset_id` | string | `ERC1155` token ID of the conditional token of the maker's order |
| `fee_rate_bps` | string | Maker's fee rate in basis points |
| `maker_address` | string | Makers address |
| `matched_amount` | string | Amount matched from the maker's order |
| `order_id` | string | ID of the maker's order |
| `outcome` | string | Outcome targeted by the maker's order (`YES` / `NO`) |
| `owner` | string | UUID of the maker |
| `price` | string | Order price |
| `side` | string | Side of the maker: `BUY` or `SELL` |
### CLOB market
#### PriceChanges
| Name | Type | Description |
| ------------------- | ------------------ | --------------------------------------------------------- |
| `m` (market) | string | Condition ID |
| `pc` (price change) | array | Price changes by book |
| `t` (timestamp) | string (timestamp) | Timestamp in milliseconds since epoch (UNIX time \* 1000) |
##### PriceChange
NOTE: Filters are mandatory for this topic/type. Example: `["100","200",...]` (collection of token ids)
| Name | Type | Description |
| --------------- | ------ | --------------------------------------------------------------- |
| `a` (asset_id) | string | Asset identifier |
| `h` (hash) | string | Unique hash ID of the book snapshot |
| `p` (price) | string | Price quoted (e.g., `0.5`) |
| `s` (side) | string | Side of the quote: `BUY` or `SELL` |
| `si` (size) | string | Size or volume available at the quoted price (e.g., `0`, `100`) |
| `ba` (best_ask) | string | Best ask price |
| `bb` (best_bid) | string | Best bid price |
#### AggOrderbook
| Name | Type | Description |
| ---------------- | ------------------ | ----------------------------------------------------------------------- |
| `asks` | array | List of ask aggregated orders (sell side), each with `price` and `size` |
| `asset_id` | string | Asset Id identifier |
| `bids` | array | List of aggregated bid orders (buy side), each with `price` and `size` |
| `hash` | string | Unique hash ID for this orderbook snapshot |
| `market` | string | Market or condition ID |
| `min_order_size` | string | Minimum allowed order size |
| `neg_risk` | boolean | NegRisk or not |
| `tick_size` | string | Minimum tick size |
| `timestamp` | string (timestamp) | Timestamp in milliseconds since epoch (UNIX time \* 1000) |
##### `asks`/`bids` scheema
| Name | Type | Description |
| ------- | ------ | ------------------ |
| `price` | string | Price level |
| `size` | string | Size at that price |
##### Initial data dump on connection
When the connection is stablished, if a `filter` is used, the server will dump an initial snapshoot of recent data
#### LastTradePrice
| Name | Type | Description |
| -------------- | ------ | ---------------------------------- |
| `asset_id` | string | Asset Id identifier |
| `fee_rate_bps` | string | Fee rate in basis points (bps) |
| `market` | string | Market or condition ID |
| `price` | string | Trade price (e.g., `0.5`) |
| `side` | string | Side of the order: `BUY` or `SELL` |
| `size` | string | Size of the trade |
#### TickSizeChange
| Name | Type | Description |
| --------------- | ------ | ------------------------------------ |
| `market` | string | Market or condition ID |
| `asset_id` | string | Array of two `ERC1155` asset ID |
| `old_tick_size` | string | Previous tick size before the change |
| `new_tick_size` | string | Updated tick size after the change |
#### ClobMarket
| Name | Type | Description |
| ---------------- | --------- | ------------------------------------------------------------------ |
| `market` | string | Market or condition ID |
| `asset_ids` | [2]string | Array of two `ERC1155` asset ID identifiers associated with market |
| `min_order_size` | string | Minimum size allowed for an order |
| `tick_size` | string | Minimum allowable price increment |
| `neg_risk` | boolean | Indicates if the market is negative risk |
-655
View File
@@ -1,655 +0,0 @@
# Polymarket - Api
**Pages:** 46
---
## Get sports metadata information
**URL:** llms-txt#get-sports-metadata-information
Source: https://docs.polymarket.com/api-reference/sports/get-sports-metadata-information
api-reference/gamma-openapi.json get /sports
Retrieves metadata for various sports including images, resolution sources, ordering preferences, tags, and series information. This endpoint provides comprehensive sport configuration data used throughout the platform.
---
## Get user activity
**URL:** llms-txt#get-user-activity
Source: https://docs.polymarket.com/api-reference/core/get-user-activity
api-reference/data-api-openapi.yaml get /activity
Returns on-chain activity for a user.
---
## Get comments by comment id
**URL:** llms-txt#get-comments-by-comment-id
Source: https://docs.polymarket.com/api-reference/comments/get-comments-by-comment-id
api-reference/gamma-openapi.json get /comments/{id}
---
## Get open interest
**URL:** llms-txt#get-open-interest
Source: https://docs.polymarket.com/api-reference/misc/get-open-interest
api-reference/data-api-openapi.yaml get /oi
---
## Get total value of a user's positions
**URL:** llms-txt#get-total-value-of-a-user's-positions
Source: https://docs.polymarket.com/api-reference/core/get-total-value-of-a-users-positions
api-reference/data-api-openapi.yaml get /value
---
## Get related tags (relationships) by tag id
**URL:** llms-txt#get-related-tags-(relationships)-by-tag-id
Source: https://docs.polymarket.com/api-reference/tags/get-related-tags-relationships-by-tag-id
api-reference/gamma-openapi.json get /tags/{id}/related-tags
---
## List events
**URL:** llms-txt#list-events
Source: https://docs.polymarket.com/api-reference/events/list-events
api-reference/gamma-openapi.json get /events
---
## Get tag by id
**URL:** llms-txt#get-tag-by-id
Source: https://docs.polymarket.com/api-reference/tags/get-tag-by-id
api-reference/gamma-openapi.json get /tags/{id}
---
## Get market by id
**URL:** llms-txt#get-market-by-id
Source: https://docs.polymarket.com/api-reference/markets/get-market-by-id
api-reference/gamma-openapi.json get /markets/{id}
---
## WSS Authentication
**URL:** llms-txt#wss-authentication
Source: https://docs.polymarket.com/developers/CLOB/websocket/wss-auth
<Tip> Only connections to `user` channel require authentication. </Tip>
| Field | Optional | Description |
| ---------- | -------- | ------------------------------------- |
| apikey | yes | Polygon account's CLOB api key |
| secret | yes | Polygon account's CLOB api secret |
| passphrase | yes | Polygon account's CLOB api passphrase |
---
## Get tags related to a tag slug
**URL:** llms-txt#get-tags-related-to-a-tag-slug
Source: https://docs.polymarket.com/api-reference/tags/get-tags-related-to-a-tag-slug
api-reference/gamma-openapi.json get /tags/slug/{slug}/related-tags/tags
---
## Get related tags (relationships) by tag slug
**URL:** llms-txt#get-related-tags-(relationships)-by-tag-slug
Source: https://docs.polymarket.com/api-reference/tags/get-related-tags-relationships-by-tag-slug
api-reference/gamma-openapi.json get /tags/slug/{slug}/related-tags
---
## Get total markets a user has traded
**URL:** llms-txt#get-total-markets-a-user-has-traded
Source: https://docs.polymarket.com/api-reference/misc/get-total-markets-a-user-has-traded
api-reference/data-api-openapi.yaml get /traded
---
## Get market by slug
**URL:** llms-txt#get-market-by-slug
Source: https://docs.polymarket.com/api-reference/markets/get-market-by-slug
api-reference/gamma-openapi.json get /markets/slug/{slug}
---
## List tags
**URL:** llms-txt#list-tags
Source: https://docs.polymarket.com/api-reference/tags/list-tags
api-reference/gamma-openapi.json get /tags
---
## Get market price
**URL:** llms-txt#get-market-price
Source: https://docs.polymarket.com/api-reference/pricing/get-market-price
api-reference/clob-subset-openapi.yaml get /price
Retrieves the market price for a specific token and side
---
## Next page of markets with tag filtering
**URL:** llms-txt#next-page-of-markets-with-tag-filtering
**Contents:**
- Best Practices
- Related Endpoints
curl "https://gamma-api.polymarket.com/markets?tag_id=100381&closed=false&limit=25&offset=25"
```
1. **For Individual Markets:** Always use the slug method for best performance
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 `closed=false`:** Unless you specifically need historical data
5. **Implement Rate Limiting:** Respect API limits for production applications
* [Get Markets](/developers/gamma-markets-api/get-markets) - Full markets endpoint documentation
* [Get Events](/developers/gamma-markets-api/get-events) - Full events endpoint documentation
* [Search Markets](/developers/gamma-markets-api/get-public-search) - Search functionality
---
## API Key Operations
**URL:** llms-txt#api-key-operations
**Contents:**
- Create API Key
- Derive API Key
- Get API Keys
- Delete API Key
- Access Status
- Get Closed Only Mode Status
<Tip>This endpoint requires an **L1 Header**.</Tip>
Create new API key credentials for a user.
<Tip>This endpoint requires an **L1 Header**. </Tip>
Derive an existing API key for an address and nonce.
<Tip>This endpoint requires an **L2 Header**. </Tip>
Retrieve all API keys associated with a Polygon address.
<Tip>This endpoint requires an **L2 Header**.</Tip>
Delete an API key used to authenticate a request.
Check the value of `cert_required` by signer address.
## Get Closed Only Mode Status
<Tip>This endpoint requires an **L2 Header**.</Tip>
Retrieve the closed-only mode flag status.
**Examples:**
Example 1 (unknown):
```unknown
***
## Derive API Key
<Tip>This endpoint requires an **L1 Header**. </Tip>
Derive an existing API key for an address and nonce.
**HTTP Request:**
```
Example 2 (unknown):
```unknown
***
## Get API Keys
<Tip>This endpoint requires an **L2 Header**. </Tip>
Retrieve all API keys associated with a Polygon address.
**HTTP Request:**
```
Example 3 (unknown):
```unknown
***
## Delete API Key
<Tip>This endpoint requires an **L2 Header**.</Tip>
Delete an API key used to authenticate a request.
**HTTP Request:**
```
Example 4 (unknown):
```unknown
***
## Access Status
Check the value of `cert_required` by signer address.
**HTTP Request:**
```
---
## List comments
**URL:** llms-txt#list-comments
Source: https://docs.polymarket.com/api-reference/comments/list-comments
api-reference/gamma-openapi.json get /comments
---
## Get trades for a user or markets
**URL:** llms-txt#get-trades-for-a-user-or-markets
Source: https://docs.polymarket.com/api-reference/core/get-trades-for-a-user-or-markets
api-reference/data-api-openapi.yaml get /trades
---
## Get event tags
**URL:** llms-txt#get-event-tags
Source: https://docs.polymarket.com/api-reference/events/get-event-tags
api-reference/gamma-openapi.json get /events/{id}/tags
---
## Create and Place an Order
**URL:** llms-txt#create-and-place-an-order
**Contents:**
- Request Payload Parameters
- Order types
- Response Format
- Insert Error Messages
- Insert Statuses
<Tip> This endpoint requires a L2 Header </Tip>
Create and place an order using the Polymarket CLOB API clients. All orders are represented as "limit" orders, but "market" orders are also supported. To place a market order, simply ensure your price is marketable against current resting limit orders, which are executed on input at the best price.
`POST /<clob-endpoint>/order`
### Request Payload Parameters
| Name | Required | Type | Description |
| --------- | -------- | ------ | -------------------------------- |
| order | yes | Order | signed object |
| owner | yes | string | api key of order owner |
| orderType | yes | string | order type ("FOK", "GTC", "GTD") |
An `order` object is the form:
| Name | Required | Type | Description |
| ------------- | -------- | ------- | -------------------------------------------------- |
| salt | yes | integer | random salt used to create unique order |
| maker | yes | string | maker address (funder) |
| signer | yes | string | signing address |
| taker | yes | string | taker address (operator) |
| tokenId | yes | string | ERC1155 token ID of conditional token being traded |
| makerAmount | yes | string | maximum amount maker is willing to spend |
| takerAmount | yes | string | minimum amount taker will pay the maker in return |
| expiration | yes | string | unix expiration timestamp |
| nonce | yes | string | maker's exchange nonce of the order is associated |
| feeRateBps | yes | string | fee rate basis points as required by the operator |
| side | yes | string | buy or sell enum index |
| signatureType | yes | integer | signature type enum index |
| signature | yes | string | hex encoded signature |
* **FOK**: A Fill-Or-Kill order is an market order to buy (in dollars) or sell (in shares) shares that must be executed immediately in its entirety; otherwise, the entire order will be cancelled.
* **FAK**: A Fill-And-Kill order is a market order to buy (in dollars) or sell (in shares) that will be executed immediately for as many shares as are available; any portion not filled at once is cancelled.
* **GTC**: A Good-Til-Cancelled order is a limit order that is active until it is fulfilled or cancelled.
* **GTD**: A Good-Til-Date order is a type of order that is active until its specified date (UTC seconds timestamp), unless it has already been fulfilled or cancelled. There is a security threshold of one minute. If the order needs to expire in 90 seconds the correct expiration value is: now + 1 minute + 30 seconds
| Name | Type | Description |
| ----------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| success | boolean | boolean indicating if server-side err (`success = false`) -> server-side error |
| errorMsg | string | error message in case of unsuccessful placement (in case `success = false`, e.g. `client-side error`, the reason is in `errorMsg`) |
| orderId | string | id of order |
| orderHashes | string\[] | hash of settlement transaction order was marketable and triggered a match |
### Insert Error Messages
If the `errorMsg` field of the response object from placement is not an empty string, the order was not able to be immediately placed. This might be because of a delay or because of a failure. If the `success` is not `true`, then there was an issue placing the order. The following `errorMessages` are possible:
| Error | Success | Message | Description |
| ------------------------------------ | ------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| INVALID\_ORDER\_MIN\_TICK\_SIZE | yes | order is invalid. Price breaks minimum tick size rules | order price isn't accurate to correct tick sizing |
| INVALID\_ORDER\_MIN\_SIZE | yes | order is invalid. Size lower than the minimum | order size must meet min size threshold requirement |
| INVALID\_ORDER\_DUPLICATED | yes | order is invalid. Duplicated. Same order has already been placed, can't be placed again | |
| INVALID\_ORDER\_NOT\_ENOUGH\_BALANCE | yes | not enough balance / allowance | funder address doesn't have sufficient balance or allowance for order |
| INVALID\_ORDER\_EXPIRATION | yes | invalid expiration | expiration field expresses a time before now |
| INVALID\_ORDER\_ERROR | yes | could not insert order | system error while inserting order |
| EXECUTION\_ERROR | yes | could not run the execution | system error while attempting to execute trade |
| ORDER\_DELAYED | no | order match delayed due to market conditions | order placement delayed |
| DELAYING\_ORDER\_ERROR | yes | error delaying the order | system error while delaying order |
| FOK\_ORDER\_NOT\_FILLED\_ERROR | yes | order couldn't be fully filled, FOK orders are fully filled/killed | FOK order not fully filled so can't be placed |
| MARKET\_NOT\_READY | no | the market is not yet ready to process new orders | system not accepting orders for market yet |
When placing an order, a status field is included. The status field provides additional information regarding the order's state as a result of the placement. Possible values include:
| Status | Description |
| --------- | ------------------------------------------------------------ |
| matched | order placed and matched with an existing resting order |
| live | order placed and resting on the book |
| delayed | order marketable, but subject to matching delay |
| unmatched | order marketable, but failure delaying, placement successful |
**Examples:**
Example 1 (unknown):
```unknown
```
---
## Get series by id
**URL:** llms-txt#get-series-by-id
Source: https://docs.polymarket.com/api-reference/series/get-series-by-id
api-reference/gamma-openapi.json get /series/{id}
---
## List markets
**URL:** llms-txt#list-markets
Source: https://docs.polymarket.com/api-reference/markets/list-markets
api-reference/gamma-openapi.json get /markets
---
## Get bid-ask spreads
**URL:** llms-txt#get-bid-ask-spreads
Source: https://docs.polymarket.com/api-reference/spreads/get-bid-ask-spreads
api-reference/clob-subset-openapi.yaml post /spreads
Retrieves bid-ask spreads for multiple tokens
---
## List series
**URL:** llms-txt#list-series
Source: https://docs.polymarket.com/api-reference/series/list-series
api-reference/gamma-openapi.json get /series
---
## Search markets, events, and profiles
**URL:** llms-txt#search-markets,-events,-and-profiles
Source: https://docs.polymarket.com/api-reference/search/search-markets-events-and-profiles
api-reference/gamma-openapi.json get /public-search
---
## Get multiple order books summaries by request
**URL:** llms-txt#get-multiple-order-books-summaries-by-request
Source: https://docs.polymarket.com/api-reference/orderbook/get-multiple-order-books-summaries-by-request
api-reference/clob-subset-openapi.yaml post /books
Retrieves order book summaries for specified tokens via POST request
---
## Get multiple market prices
**URL:** llms-txt#get-multiple-market-prices
Source: https://docs.polymarket.com/api-reference/pricing/get-multiple-market-prices
api-reference/clob-subset-openapi.yaml get /prices
Retrieves market prices for multiple tokens and sides
---
## Get midpoint price
**URL:** llms-txt#get-midpoint-price
Source: https://docs.polymarket.com/api-reference/pricing/get-midpoint-price
api-reference/clob-subset-openapi.yaml get /midpoint
Retrieves the midpoint price for a specific token
---
## List teams
**URL:** llms-txt#list-teams
Source: https://docs.polymarket.com/api-reference/sports/list-teams
api-reference/gamma-openapi.json get /teams
---
## Get current positions for a user
**URL:** llms-txt#get-current-positions-for-a-user
Source: https://docs.polymarket.com/api-reference/core/get-current-positions-for-a-user
api-reference/data-api-openapi.yaml get /positions
Returns positions filtered by user and optional filters.
---
## Health check
**URL:** llms-txt#health-check
Source: https://docs.polymarket.com/api-reference/health/health-check
api-reference/data-api-openapi.yaml get /
---
## Get tags related to a tag id
**URL:** llms-txt#get-tags-related-to-a-tag-id
Source: https://docs.polymarket.com/api-reference/tags/get-tags-related-to-a-tag-id
api-reference/gamma-openapi.json get /tags/{id}/related-tags/tags
---
## Get multiple market prices by request
**URL:** llms-txt#get-multiple-market-prices-by-request
Source: https://docs.polymarket.com/api-reference/pricing/get-multiple-market-prices-by-request
api-reference/clob-subset-openapi.yaml post /prices
Retrieves market prices for specified tokens and sides via POST request
---
## Get market tags by id
**URL:** llms-txt#get-market-tags-by-id
Source: https://docs.polymarket.com/api-reference/markets/get-market-tags-by-id
api-reference/gamma-openapi.json get /markets/{id}/tags
---
## Get closed positions for a user
**URL:** llms-txt#get-closed-positions-for-a-user
Source: https://docs.polymarket.com/api-reference/core/get-closed-positions-for-a-user
api-reference/data-api-openapi.yaml get /closed-positions
Fetches closed positions for a user(address)
---
## Get event by slug
**URL:** llms-txt#get-event-by-slug
Source: https://docs.polymarket.com/api-reference/events/get-event-by-slug
api-reference/gamma-openapi.json get /events/slug/{slug}
---
## Get live volume for an event
**URL:** llms-txt#get-live-volume-for-an-event
Source: https://docs.polymarket.com/api-reference/misc/get-live-volume-for-an-event
api-reference/data-api-openapi.yaml get /live-volume
---
## Get tag by slug
**URL:** llms-txt#get-tag-by-slug
Source: https://docs.polymarket.com/api-reference/tags/get-tag-by-slug
api-reference/gamma-openapi.json get /tags/slug/{slug}
---
## Get comments by user address
**URL:** llms-txt#get-comments-by-user-address
Source: https://docs.polymarket.com/api-reference/comments/get-comments-by-user-address
api-reference/gamma-openapi.json get /comments/user_address/{user_address}
---
## Get order book summary
**URL:** llms-txt#get-order-book-summary
Source: https://docs.polymarket.com/api-reference/orderbook/get-order-book-summary
api-reference/clob-subset-openapi.yaml get /book
Retrieves the order book summary for a specific token
---
## Endpoint
**URL:** llms-txt#endpoint
[https://gamma-api.polymarket.com](https://gamma-api.polymarket.com)
---
## Get top holders for markets
**URL:** llms-txt#get-top-holders-for-markets
Source: https://docs.polymarket.com/api-reference/core/get-top-holders-for-markets
api-reference/data-api-openapi.yaml get /holders
---
## Get event by id
**URL:** llms-txt#get-event-by-id
Source: https://docs.polymarket.com/api-reference/events/get-event-by-id
api-reference/gamma-openapi.json get /events/{id}
---
## Get price history for a traded token
**URL:** llms-txt#get-price-history-for-a-traded-token
Source: https://docs.polymarket.com/api-reference/pricing/get-price-history-for-a-traded-token
api-reference/clob-subset-openapi.yaml get /prices-history
Fetches historical price data for a specified market token
---
@@ -1,370 +0,0 @@
# Polymarket - Getting Started
**Pages:** 8
---
## CLOB Introduction
**URL:** llms-txt#clob-introduction
**Contents:**
- System
- API
- Security
- Fees
- Schedule
- Overview
- Additional Resources
Source: https://docs.polymarket.com/developers/CLOB/introduction
Welcome to the Polymarket Order Book API! This documentation provides overviews, explanations, examples, and annotations to simplify interaction with the order book. The following sections detail the Polymarket Order Book and the API usage.
Polymarket's Order Book, or CLOB (Central Limit Order Book), is hybrid-decentralized. It includes an operator for off-chain matching/ordering, with settlement executed on-chain, non-custodially, via signed order messages.
The exchange uses a custom Exchange contract facilitating atomic swaps between binary Outcome Tokens (CTF ERC1155 assets and ERC20 PToken assets) and collateral assets (ERC20), following signed limit orders. Designed for binary markets, the contract enables complementary tokens to match across a unified order book.
Orders are EIP712-signed structured data. Matched orders have one maker and one or more takers, with price improvements benefiting the taker. The operator handles off-chain order management and submits matched trades to the blockchain for on-chain execution.
The Polymarket Order Book API enables market makers and traders to programmatically manage market orders. Orders of any amount can be created, listed, fetched, or read from the market order books. Data includes all available markets, market prices, and order history via REST and WebSocket endpoints.
Polymarket's Exchange contract has been audited by Chainsecurity ([View Audit](https://github.com/Polymarket/ctf-exchange/blob/main/audit/ChainSecurity_Polymarket_Exchange_audit.pdf)).
The operator's privileges are limited to order matching, non-censorship, and ensuring correct ordering. Operators can't set prices or execute unauthorized trades. Users can cancel orders on-chain independently if trust issues arise.
| Volume Level | Maker Fee Base Rate (bps) | Taker Fee Base Rate (bps) |
| ------------ | ------------------------- | ------------------------- |
| >0 USDC | 0 | 0 |
Fees apply symmetrically in output assets (proceeds). This symmetry ensures fairness and market integrity. Fees are calculated differently depending on whether you are buying or selling:
* **Selling outcome tokens (base) for collateral (quote):**
$$
feeQuote = baseRate \times \min(price, 1 - price) \times size
$$
* **Buying outcome tokens (base) with collateral (quote):**
$$
feeBase = baseRate \times \min(price, 1 - price) \times \frac{size}{price}
$$
## Additional Resources
* [Exchange contract source code](https://github.com/Polymarket/ctf-exchange/tree/main/src)
* [Exchange contract documentation](https://github.com/Polymarket/ctf-exchange/blob/main/docs/Overview.md)
---
## API Rate Limits
**URL:** llms-txt#api-rate-limits
**Contents:**
- How Rate Limiting Works
- General Rate Limits
- Data API Rate Limits
- GAMMA API Rate Limits
- CLOB API Rate Limits
- General CLOB Endpoints
- CLOB Market Data
- CLOB Ledger Endpoints
- CLOB Markets & Pricing
- CLOB Authentication
Source: https://docs.polymarket.com/quickstart/introduction/rate-limits
## How Rate Limiting Works
All rate limits are enforced using Cloudflare's throttling system. When you exceed the maximum configured rate for any endpoint, requests are throttled rather than immediately rejected. This means:
* **Throttling**: Requests over the limit are delayed/queued rather than dropped
* **Burst Allowances**: Some endpoints allow short bursts above the sustained rate
* **Time Windows**: Limits reset based on sliding time windows (e.g., per 10 seconds, per minute)
## General Rate Limits
| Endpoint | Limit | Notes |
| --------------------- | ------------------- | -------------------------------------------------- |
| General Rate Limiting | 5000 requests / 10s | Throttle requests over the maximum configured rate |
| "OK" Endpoint | 50 requests / 10s | Throttle requests over the maximum configured rate |
## Data API Rate Limits
| Endpoint | Limit | Notes |
| ---------------------- | ------------------------ | -------------------------------------------------- |
| Data API (General) | 200 requests / 10s | Throttle requests over the maximum configured rate |
| Data API (Alternative) | 1200 requests / 1 minute | 10 minutes block on violation |
| Data API `/trades` | 75 requests / 10s | Throttle requests over the maximum configured rate |
| Data API "OK" Endpoint | 10 requests / 10s | Throttle requests over the maximum configured rate |
## GAMMA API Rate Limits
| Endpoint | Limit | Notes |
| -------------------------------- | ------------------ | -------------------------------------------------- |
| GAMMA (General) | 750 requests / 10s | Throttle requests over the maximum configured rate |
| GAMMA Get Comments | 100 requests / 10s | Throttle requests over the maximum configured rate |
| GAMMA `/events` | 100 requests / 10s | Throttle requests over the maximum configured rate |
| GAMMA `/markets` | 125 requests / 10s | Throttle requests over the maximum configured rate |
| GAMMA `/markets` /events listing | 100 requests / 10s | Throttle requests over the maximum configured rate |
| GAMMA Tags | 100 requests / 10s | Throttle requests over the maximum configured rate |
| GAMMA Search | 300 requests / 10s | Throttle requests over the maximum configured rate |
## CLOB API Rate Limits
### General CLOB Endpoints
| Endpoint | Limit | Notes |
| ----------------------------- | ------------------- | -------------------------------------------------- |
| CLOB (General) | 5000 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB GET Balance Allowance | 125 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB UPDATE Balance Allowance | 20 requests / 10s | Throttle requests over the maximum configured rate |
| Endpoint | Limit | Notes |
| ----------------- | ------------------ | -------------------------------------------------- |
| CLOB `/book` | 200 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB `/books` | 80 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB `/price` | 200 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB `/prices` | 80 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB `/midprice` | 200 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB `/midprices` | 80 requests / 10s | Throttle requests over the maximum configured rate |
### CLOB Ledger Endpoints
| Endpoint | Limit | Notes |
| ----------------------------------------------------------- | ------------------ | -------------------------------------------------- |
| CLOB Ledger (`/trades` `/orders` `/notifications` `/order`) | 300 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB Ledger `/data/orders` | 150 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB Ledger `/data/trades` | 150 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB `/notifications` | 125 requests / 10s | Throttle requests over the maximum configured rate |
### CLOB Markets & Pricing
| Endpoint | Limit | Notes |
| ----------------------- | ------------------ | -------------------------------------------------- |
| CLOB Price History | 100 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB Markets | 250 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB Market Tick Size | 50 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB `markets/0x` | 50 requests / 10s | Throttle requests over the maximum configured rate |
| CLOB `/markets` listing | 100 requests / 10s | Throttle requests over the maximum configured rate |
### CLOB Authentication
| Endpoint | Limit | Notes |
| ------------- | ----------------- | -------------------------------------------------- |
| CLOB API Keys | 50 requests / 10s | Throttle requests over the maximum configured rate |
### CLOB Trading Endpoints
| Endpoint | Limit | Notes |
| ----------------------------------- | ---------------------------------- | ---------------------------------------------------------- |
| CLOB POST `/order` | 2400 requests / 10s (240/s) | BURST - Throttle requests over the maximum configured rate |
| CLOB POST `/order` | 24000 requests / 10 minutes (40/s) | Throttle requests over the maximum configured rate |
| CLOB DELETE `/order` | 2400 requests / 10s (240/s) | BURST - Throttle requests over the maximum configured rate |
| CLOB DELETE `/order` | 24000 requests / 10 minutes (40/s) | Throttle requests over the maximum configured rate |
| CLOB POST `/orders` | 800 requests / 10s (80/s) | BURST - Throttle requests over the maximum configured rate |
| CLOB POST `/orders` | 12000 requests / 10 minutes (20/s) | Throttle requests over the maximum configured rate |
| CLOB DELETE `/orders` | 800 requests / 10s (80/s) | BURST - Throttle requests over the maximum configured rate |
| CLOB DELETE `/orders` | 12000 requests / 10 minutes (20/s) | Throttle requests over the maximum configured rate |
| CLOB DELETE `/cancel-all` | 200 requests / 10s (20/s) | BURST - Throttle requests over the maximum configured rate |
| CLOB DELETE `/cancel-all` | 3000 requests / 10 minutes (5/s) | Throttle requests over the maximum configured rate |
| CLOB DELETE `/cancel-market-orders` | 800 requests / 10s (80/s) | BURST - Throttle requests over the maximum configured rate |
| CLOB DELETE `/cancel-market-orders` | 12000 requests / 10 minutes (20/s) | Throttle requests over the maximum configured rate |
## Other API Rate Limits
| Endpoint | Limit | Notes |
| ----------------- | ---------------------- | -------------------------------------------------- |
| RELAYER `/submit` | 15 requests / 1 minute | Throttle requests over the maximum configured rate |
| User PNL API | 100 requests / 10s | Throttle requests over the maximum configured rate |
---
## Glossary
**URL:** llms-txt#glossary
Source: https://docs.polymarket.com/quickstart/introduction/definitions
| Term | Definition |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Token** | A token represents a stake in a specific Yes/No outcome in a Market. The price of a token can fluctuate between $0 - $1 based on the market belief in the outcome. When a market resolves, the token associated with the correct prediction can be redeemed for \$1 USDC. This is also sometimes called an *Asset Id* |
| **Market** | A single event outcome. Corresponds to a pair of CLOB token IDs(Yes/No), a market address, a question ID and a condition ID. |
| **Event** | A collection of related markets grouped under a common topic or theme. |
| **SLUG** | A human readable identification for a market or event. Can be found in the URL of any Polymarket Market or Event. You can use this slug to find more detailed information about a market or event by using it as a parameter in the [Get Events](/developers/gamma-markets-api/get-events) or [Get Markets](/developers/gamma-markets-api/get-markets) endpoints. |
| **Negative Risk (negrisk)** | A group of Markets(Event) in which only one Market can resolve as yes. For more detail see [Negrisk Details](https://docs.polymarket.com/developers/neg-risk/overview) |
| **Central Limit Order Book** | The off-chain order matching system. This is where you place resting orders and market orders are matched with existing orders before being sent on-chain. |
| **Polygon Network** | A scalable, multi-chain blockchain platform used by Polymarket to facilitate on-chain activities(contract creation, token transfers, etc) |
---
## WSS Quickstart
**URL:** llms-txt#wss-quickstart
**Contents:**
- Getting your API Keys
- Using those keys to connect to the Market or User Websocket
Source: https://docs.polymarket.com/quickstart/websocket/WSS-Quickstart
The following code samples and explanation will show you how to subsribe to the Marker and User channels of the Websocket.
You'll need your API keys to do this so we'll start with that.
## Getting your API Keys
## Using those keys to connect to the Market or User Websocket
<CodeGroup>
</CodeGroup>
**Examples:**
Example 1 (unknown):
```unknown
```
Example 2 (unknown):
```unknown
</CodeGroup>
## Using those keys to connect to the Market or User Websocket
<CodeGroup>
```
---
## Does Polymarket have an API?
**URL:** llms-txt#does-polymarket-have-an-api?
Source: https://docs.polymarket.com/polymarket-learn/FAQ/does-polymarket-have-an-api
Getting data from Polymarket
Yes! Developers can find all the information they need for interacting with Polymarket. This includes [documentation on market discovery, resolution, trading etc.](/quickstart/introduction/main)
Whether you are an academic researcher a market maker or an indepedent developer, this documentation should provide you what you need to get started. All the code you find linked here and on our [GitHub](https://github.com/polymarket) is open source and free to use.
<Tip>
If you have any questions please join our [Discord](https://discord.com/invite/polymarket) and direct your questions to the #devs channel.
</Tip>
---
## Developer Quickstart
**URL:** llms-txt#developer-quickstart
Source: https://docs.polymarket.com/quickstart/introduction/main
This section of the documentation will provide all the essential resources to help you perform basic trading actions on the Polymarket platform. If you're just getting started, you're in the right place.
Everything you need to start building with the Polymarket API is right here. Lets get started.
[Not sure what to build next? Get inspired by checking out real examples from other developers using the API.](/quickstart/introduction/showcase)
---
## What is a Prediction Market?
**URL:** llms-txt#what-is-a-prediction-market?
**Contents:**
- How it works
- Making predictions
- Free-market trading
- Trust the markets
Source: https://docs.polymarket.com/polymarket-learn/FAQ/what-are-prediction-markets
How people collectively forecast the future.
A prediction market is a platform where people can bet on the outcome of future events. By buying and selling shares in the outcomes, participants collectively forecast the likelihood of events such as sports results, political elections, or entertainment awards.
Market Prices = Probabilities: The price of shares in a prediction market represents the current probability of an event happening. For example, if shares of an event are trading at 20 cents, it indicates a 20% chance of that event occurring.
### Making predictions
If you believe the actual probability of an event is higher than the market price suggests, you can buy shares. For instance, if you think a team has a better than 20% chance of winning, you would buy shares at 20 cents. If the event occurs, each share becomes worth \$1, yielding a profit.
### Free-market trading
You can buy or sell shares at any time before the event concludes, based on new information or changing circumstances. This flexibility allows the market prices to continuously reflect the most current and accurate probabilities.
### Trust the markets
Prediction markets provide unbiased and accurate probabilities in real time, cutting through the noise of human and media biases. Traditional sources often have their own incentives and slants, but prediction markets operate on the principle of "put your money where your mouth is." Here, participants are financially motivated to provide truthful insights, as their profits depend on the accuracy of their predictions.
In a prediction market, prices reflect the aggregated sentiment of all participants, weighing news, data, expert opinions, and culture to determine the true odds. Unlike media narratives, which can be swayed by various biases, prediction markets offer a transparent view of where people genuinely believe we're heading.
#### Why use prediction markets?
Prediction markets are often more accurate than traditional polls and expert predictions. The collective wisdom of diverse participants, each motivated by the potential for profit, leads to highly reliable forecasts. This makes prediction markets an excellent tool for gauging real-time probabilities of future events.
Polymarket, the world's largest prediction market, offers a user-friendly platform to bet on a wide range of topics, from sports to politics. By participating, you can profit from your knowledge while contributing to the accuracy of market predictions.
---
## What is Polymarket?
**URL:** llms-txt#what-is-polymarket?
**Contents:**
- Quick Overview
- Understanding Prices
- Making money on markets
- How accurate are Polymarket odds?
Source: https://docs.polymarket.com/polymarket-learn/get-started/what-is-polymarket
Polymarket is the worlds largest prediction market, allowing you to stay informed and profit from your knowledge by betting on future events across various topics.
Studies show prediction markets are often more accurate than pundits because they combine news, polls, and expert opinions into a single value that represents the market's view of an event's odds. Our markets reflect *accurate, unbiased, and real-time probabilities* for the events that matter most to you. Markets seek truth.
* On Polymarket, you can [buy and sell shares](making-your-first-trade) representing future event outcomes (i.e. "Will TikTok be banned in the U.S. this year?")
* Shares in event outcomes are [always priced](what-is-polymarket/#understanding-prices) between 0.00 and 1.00 [USDC](../FAQ/why-do-i-need-crypto/#why-usdc), and every pair of event outcomes (i.e. each pair of "YES" + "NO" shares) is fully collateralized by \$1.00 USDC.
* Shares are created when [opposing sides come to an agreement on odds](../trading/limit-orders), such that the sum of what each side is willing to pay is equal to \$1.00.
* The shares representing the *correct, final outcome* are paid out \$1.00 USDC each upon [market resolution](../markets/how-are-markets-resolved).
* Unlike sportsbooks, you are not betting against "the house" the counterparty to each trade is another Polymarket user. As such:
* Shares can be sold before the event outcome is known\_ (i.e. to lock in profits or cut losses)
* *There is no "house" to ban you for winning too much.*
### Understanding Prices
Prices = Probabilities.
<VideoPlayer src="https://www.youtube.com/embed/v0CvPEYBzTI?si=9cirMPQ72orQzLyS" />
*Prices (odds) on Polymarket represent the current probability of an event occurring.* For example, in a market predicting whether the Miami Heat will win the 2025 NBA Finals, if YES shares are trading at 18 cents, it indicates a 18% chance of Miami winning.
These odds are determined by what price other Polymarket users are currently willing to buy & sell those shares at. Just how stock exchanges don't "set" the prices of stocks, Polymarket does not set prices / odds - they're a function of supply & demand.
[Learn more >](/docs/guides/trading/how-are-prices-calculated)
### Making money on markets
In the example above, if you believe Miami's chances of winning are higher than 18%, you would buy “Yes” shares at 18 cents each. If Miami wins, each “Yes” share would be worth \$1, resulting in an 82-cent profit per share. Conversely, any trader who owned “No” shares would see their investment become worthless once the game is over.
Since it's a market, you're not locked into your trade. You can sell your shares at any time at the current market price. As the news changes, the supply and demand for shares fluctuates, causing the share price to reflect the new odds for the event.
### How accurate are Polymarket odds?
Research shows prediction markets are often more accurate than experts, polls, and pundits. Traders aggregate news, polls, and expert opinions, making informed trades. Their economic incentives ensure market prices adjust to reflect true odds as more knowledgeable participants join.
This makes prediction markets the best source of real-time event probabilities. People use Polymarket for the most accurate odds, gaining the ability to make informed decisions about the future.
If you're an expert on a certain topic, Polymarket is your opportunity to profit from trading based on your knowledge, while improving the market's accuracy.
---
-235
View File
@@ -1,235 +0,0 @@
# Polymarket - Guides
**Pages:** 3
---
## Example
**URL:** llms-txt#example
* **\[Event]** Where will Barron Trump attend College?
* **\[Market]** Will Barron attend Georgetown?
* **\[Market]** Will Barron attend NYU?
* **\[Market]** Will Barron attend UPenn?
* **\[Market]** Will Barron attend Harvard?
* **\[Market]** Will Barron attend another college?
---
## How to Fetch Markets
**URL:** llms-txt#how-to-fetch-markets
**Contents:**
- Overview
- 1. Fetch by Slug
- How to Extract the Slug
- API Endpoints
- Examples
- 2. Fetch by Tags
- Discover Available Tags
- Using Tags in Market Requests
- Additional Tag Filtering
- 3. Fetch All Active Markets
Source: https://docs.polymarket.com/developers/gamma-markets-api/fetch-markets-guide
<Tip>Both the getEvents and getMarkets are paginated. See [pagination section](#pagination) for details.</Tip>
This guide covers the three recommended approaches for fetching market data from the Gamma API, each optimized for different use cases.
There are three main strategies for retrieving market data:
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
**Use Case:** When you need to retrieve a specific market or event that you already know about.
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/` or `/market/`:
**For Events:** [GET /events/slug/{slug}](/api-reference/events/list-events)
**For Markets:** [GET /markets/slug/{slug}](/api-reference/markets/list-markets)
**Use Case:** When you want to filter markets by category, sport, or topic.
Tags provide a powerful way to categorize and filter markets. You can discover available tags and then use them to filter your market requests.
### Discover Available Tags
**General Tags:** [GET /tags](/api-reference/tags/list-tags)
**Sports Tags & Metadata:** [GET /sports](/api-reference/sports/get-sports-metadata-information)
The `/sports` endpoint returns comprehensive metadata for sports including tag IDs, images, resolution sources, and series information.
### Using Tags in Market Requests
Once you have tag IDs, you can use them with the `tag_id` parameter in both markets and events endpoints.
**Markets with Tags:** [GET /markets](/api-reference/markets/list-markets)
**Events with Tags:** [GET /events](/api-reference/events/list-events)
### Additional Tag Filtering
* Use `related_tags=true` to include related tag markets
* Exclude specific tags with `exclude_tag_id`
## 3. Fetch All Active Markets
**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 and work backwards, as events contain their associated markets.
**Events Endpoint:** [GET /events](/api-reference/events/list-events)
**Markets Endpoint:** [GET /markets](/api-reference/markets/list-markets)
* `order=id` - Order by event ID
* `ascending=false` - Get newest events first
* `closed=false` - Only active markets
* `limit` - Control response size
* `offset` - For pagination
This approach gives you all active markets ordered from newest to oldest, allowing you to systematically process all available trading opportunities.
For large datasets, use pagination with `limit` and `offset` parameters:
* `limit=50` - Return 50 results per page
* `offset=0` - Start from the beginning (increment by limit for subsequent pages)
**Pagination Examples:**
```bash theme={null}
**Examples:**
Example 1 (unknown):
```unknown
https://polymarket.com/event/fed-decision-in-october?tid=1758818660485
Slug: fed-decision-in-october
```
Example 2 (unknown):
```unknown
***
## 2. Fetch by Tags
**Use Case:** When you want to filter markets by category, sport, or topic.
Tags provide a powerful way to categorize and filter markets. You can discover available tags and then use them to filter your market requests.
### Discover Available Tags
**General Tags:** [GET /tags](/api-reference/tags/list-tags)
**Sports Tags & Metadata:** [GET /sports](/api-reference/sports/get-sports-metadata-information)
The `/sports` endpoint returns comprehensive metadata for sports including tag IDs, images, resolution sources, and series information.
### Using Tags in Market Requests
Once you have tag IDs, you can use them with the `tag_id` parameter in both markets and events endpoints.
**Markets with Tags:** [GET /markets](/api-reference/markets/list-markets)
**Events with Tags:** [GET /events](/api-reference/events/list-events)
```
Example 3 (unknown):
```unknown
### Additional Tag Filtering
You can also:
* Use `related_tags=true` to include related tag markets
* Exclude specific tags with `exclude_tag_id`
***
## 3. Fetch All Active Markets
**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 and work backwards, as events contain their associated markets.
**Events Endpoint:** [GET /events](/api-reference/events/list-events)
**Markets Endpoint:** [GET /markets](/api-reference/markets/list-markets)
### Key Parameters
* `order=id` - Order by event ID
* `ascending=false` - Get newest events first
* `closed=false` - Only active markets
* `limit` - Control response size
* `offset` - For pagination
### Examples
```
Example 4 (unknown):
```unknown
This approach gives you all active markets ordered from newest to oldest, allowing you to systematically process all available trading opportunities.
### Pagination
For large datasets, use pagination with `limit` and `offset` parameters:
* `limit=50` - Return 50 results per page
* `offset=0` - Start from the beginning (increment by limit for subsequent pages)
**Pagination Examples:**
```
---
## Market Orders
**URL:** llms-txt#market-orders
**Contents:**
- Video Walkthrough
- Placing a Market Order
Once you've [signed up](../get-started/how-to-signup) and [deposited funds](../get-started/how-to-deposit), you're ready to start trading on Polymarket. Here's a step-by-step guide to get you started.
<iframe width="560" height="315" src="https://www.youtube.com/embed/1lFgkHLqo28?si=i7e61-roRsOVeRMW" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen />
## Placing a Market Order
\_Before trading, you'll want to visit the [markets page](https://polymarket.com/markets) to find a market that interests you.
<Steps>
<Steps.Step>
### [Choose a market](https://polymarket.com/markets)
Locate the 'buy' modal, on the right side of the screen. Click the outcome you want to buy (usually Yes or No), then enter the dollar amount you wish to invest.
</Steps.Step>
<Steps.Step>
### Buy shares
Click **Buy** and confirm the transaction in your wallet. Once your trade goes through, you'll receive a notification confirming its success.
<Tip>Congrats, you're officially a Polymarket trader!</Tip>
</Steps.Step>
<Steps.Step>
### Share your bet slip
You'll also see a bet slip to share on social media. We love sending \$\$\$ to traders who post their trades on Twitter and tag us!
</Steps.Step>
</Steps>
Simple, right? If you think you've got the hang of it, it's time to learn about more advanced trading and order types. [Limit Orders](../trading/limit-orders/).
---
-24
View File
@@ -1,24 +0,0 @@
# Polymarket Documentation Index
## Platform Documentation
- **api.md** - Polymarket API documentation
- **getting_started.md** - Getting started guide
- **guides.md** - Development guides
- **learn.md** - Learning resources
- **trading.md** - Trading and market operations
- **other.md** - Additional resources and tools
## Real-Time Data Streaming
- **realtime-client.md** - WebSocket real-time data client (complete API reference)
- **README.md** - Platform overview
## LLM Integration
- **llms.md** - LLM integration guide (summary)
- **llms-full.md** - Complete LLM documentation
---
**Use these reference files for detailed information on specific topics.**
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-127
View File
@@ -1,127 +0,0 @@
# Polymarket Documentation
## Docs
- [Get comments by comment id](https://docs.polymarket.com/api-reference/comments/get-comments-by-comment-id.md)
- [Get comments by user address](https://docs.polymarket.com/api-reference/comments/get-comments-by-user-address.md)
- [List comments](https://docs.polymarket.com/api-reference/comments/list-comments.md)
- [Get closed positions for a user](https://docs.polymarket.com/api-reference/core/get-closed-positions-for-a-user.md): Fetches closed positions for a user(address)
- [Get current positions for a user](https://docs.polymarket.com/api-reference/core/get-current-positions-for-a-user.md): Returns positions filtered by user and optional filters.
- [Get top holders for markets](https://docs.polymarket.com/api-reference/core/get-top-holders-for-markets.md)
- [Get total value of a user's positions](https://docs.polymarket.com/api-reference/core/get-total-value-of-a-users-positions.md)
- [Get trades for a user or markets](https://docs.polymarket.com/api-reference/core/get-trades-for-a-user-or-markets.md)
- [Get user activity](https://docs.polymarket.com/api-reference/core/get-user-activity.md): Returns on-chain activity for a user.
- [Get event by id](https://docs.polymarket.com/api-reference/events/get-event-by-id.md)
- [Get event by slug](https://docs.polymarket.com/api-reference/events/get-event-by-slug.md)
- [Get event tags](https://docs.polymarket.com/api-reference/events/get-event-tags.md)
- [List events](https://docs.polymarket.com/api-reference/events/list-events.md)
- [Health check](https://docs.polymarket.com/api-reference/health/health-check.md)
- [Get market by id](https://docs.polymarket.com/api-reference/markets/get-market-by-id.md)
- [Get market by slug](https://docs.polymarket.com/api-reference/markets/get-market-by-slug.md)
- [Get market tags by id](https://docs.polymarket.com/api-reference/markets/get-market-tags-by-id.md)
- [List markets](https://docs.polymarket.com/api-reference/markets/list-markets.md)
- [Get live volume for an event](https://docs.polymarket.com/api-reference/misc/get-live-volume-for-an-event.md)
- [Get open interest](https://docs.polymarket.com/api-reference/misc/get-open-interest.md)
- [Get total markets a user has traded](https://docs.polymarket.com/api-reference/misc/get-total-markets-a-user-has-traded.md)
- [Get multiple order books summaries by request](https://docs.polymarket.com/api-reference/orderbook/get-multiple-order-books-summaries-by-request.md): Retrieves order book summaries for specified tokens via POST request
- [Get order book summary](https://docs.polymarket.com/api-reference/orderbook/get-order-book-summary.md): Retrieves the order book summary for a specific token
- [Get market price](https://docs.polymarket.com/api-reference/pricing/get-market-price.md): Retrieves the market price for a specific token and side
- [Get midpoint price](https://docs.polymarket.com/api-reference/pricing/get-midpoint-price.md): Retrieves the midpoint price for a specific token
- [Get multiple market prices](https://docs.polymarket.com/api-reference/pricing/get-multiple-market-prices.md): Retrieves market prices for multiple tokens and sides
- [Get multiple market prices by request](https://docs.polymarket.com/api-reference/pricing/get-multiple-market-prices-by-request.md): Retrieves market prices for specified tokens and sides via POST request
- [Get price history for a traded token](https://docs.polymarket.com/api-reference/pricing/get-price-history-for-a-traded-token.md): Fetches historical price data for a specified market token
- [Search markets, events, and profiles](https://docs.polymarket.com/api-reference/search/search-markets-events-and-profiles.md)
- [Get series by id](https://docs.polymarket.com/api-reference/series/get-series-by-id.md)
- [List series](https://docs.polymarket.com/api-reference/series/list-series.md)
- [Get sports metadata information](https://docs.polymarket.com/api-reference/sports/get-sports-metadata-information.md): Retrieves metadata for various sports including images, resolution sources, ordering preferences, tags, and series information. This endpoint provides comprehensive sport configuration data used throughout the platform.
- [List teams](https://docs.polymarket.com/api-reference/sports/list-teams.md)
- [Get bid-ask spreads](https://docs.polymarket.com/api-reference/spreads/get-bid-ask-spreads.md): Retrieves bid-ask spreads for multiple tokens
- [Get related tags (relationships) by tag id](https://docs.polymarket.com/api-reference/tags/get-related-tags-relationships-by-tag-id.md)
- [Get related tags (relationships) by tag slug](https://docs.polymarket.com/api-reference/tags/get-related-tags-relationships-by-tag-slug.md)
- [Get tag by id](https://docs.polymarket.com/api-reference/tags/get-tag-by-id.md)
- [Get tag by slug](https://docs.polymarket.com/api-reference/tags/get-tag-by-slug.md)
- [Get tags related to a tag id](https://docs.polymarket.com/api-reference/tags/get-tags-related-to-a-tag-id.md)
- [Get tags related to a tag slug](https://docs.polymarket.com/api-reference/tags/get-tags-related-to-a-tag-slug.md)
- [List tags](https://docs.polymarket.com/api-reference/tags/list-tags.md)
- [Polymarket Changelog](https://docs.polymarket.com/changelog/changelog.md): Welcome to the Polymarket Changelog. Here you will find any important changes to Polymarket, including but not limited to CLOB, API, UI and Mobile Applications.
- [null](https://docs.polymarket.com/developers/CLOB/authentication.md)
- [null](https://docs.polymarket.com/developers/CLOB/clients.md)
- [null](https://docs.polymarket.com/developers/CLOB/endpoints.md)
- [CLOB Introduction](https://docs.polymarket.com/developers/CLOB/introduction.md)
- [Cancel Orders(s)](https://docs.polymarket.com/developers/CLOB/orders/cancel-orders.md): Multiple endpoints to cancel a single order, multiple orders, all orders or all orders from a single market.
- [Check Order Reward Scoring](https://docs.polymarket.com/developers/CLOB/orders/check-scoring.md): Check if an order is eligble or scoring for Rewards purposes
- [Place Single Order](https://docs.polymarket.com/developers/CLOB/orders/create-order.md): Detailed instructions for creating, placing, and managing orders using Polymarket's CLOB API.
- [Place Multiple Orders (Batching)](https://docs.polymarket.com/developers/CLOB/orders/create-order-batch.md): Instructions for placing multiple orders(Batch)
- [Get Active Orders](https://docs.polymarket.com/developers/CLOB/orders/get-active-order.md)
- [Get Order](https://docs.polymarket.com/developers/CLOB/orders/get-order.md): Get information about an existing order
- [Onchain Order Info](https://docs.polymarket.com/developers/CLOB/orders/onchain-order-info.md)
- [Orders Overview](https://docs.polymarket.com/developers/CLOB/orders/orders.md): Detailed instructions for creating, placing, and managing orders using Polymarket's CLOB API.
- [null](https://docs.polymarket.com/developers/CLOB/status.md)
- [Get Trades](https://docs.polymarket.com/developers/CLOB/trades/trades.md)
- [Trades Overview](https://docs.polymarket.com/developers/CLOB/trades/trades-overview.md)
- [Market Channel](https://docs.polymarket.com/developers/CLOB/websocket/market-channel.md)
- [User Channel](https://docs.polymarket.com/developers/CLOB/websocket/user-channel.md)
- [WSS Authentication](https://docs.polymarket.com/developers/CLOB/websocket/wss-auth.md)
- [WSS Overview](https://docs.polymarket.com/developers/CLOB/websocket/wss-overview.md): Overview and general information about the Polymarket Websocket
- [Deployment and Additional Information](https://docs.polymarket.com/developers/CTF/deployment-resources.md)
- [Merging Tokens](https://docs.polymarket.com/developers/CTF/merge.md)
- [Overview](https://docs.polymarket.com/developers/CTF/overview.md)
- [Reedeeming Tokens](https://docs.polymarket.com/developers/CTF/redeem.md)
- [Splitting USDC](https://docs.polymarket.com/developers/CTF/split.md)
- [RTDS Comments](https://docs.polymarket.com/developers/RTDS/RTDS-comments.md)
- [RTDS Crypto Prices](https://docs.polymarket.com/developers/RTDS/RTDS-crypto-prices.md)
- [Real Time Data Socket](https://docs.polymarket.com/developers/RTDS/RTDS-overview.md)
- [How to Fetch Markets](https://docs.polymarket.com/developers/gamma-markets-api/fetch-markets-guide.md)
- [Gamma Structure](https://docs.polymarket.com/developers/gamma-markets-api/gamma-structure.md)
- [null](https://docs.polymarket.com/developers/gamma-markets-api/overview.md)
- [Overview](https://docs.polymarket.com/developers/neg-risk/overview.md)
- [null](https://docs.polymarket.com/developers/proxy-wallet.md)
- [Resolution](https://docs.polymarket.com/developers/resolution/UMA.md)
- [Liquidity Rewards](https://docs.polymarket.com/developers/rewards/overview.md): Polymarket provides incentives aimed at catalyzing the supply and demand side of the marketplace. Specifically there is a public liquidity rewards program as well as one-off public pnl/volume competitions.
- [null](https://docs.polymarket.com/developers/subgraph/overview.md)
- [Does Polymarket have an API?](https://docs.polymarket.com/polymarket-learn/FAQ/does-polymarket-have-an-api.md): Getting data from Polymarket
- [How To Use Embeds](https://docs.polymarket.com/polymarket-learn/FAQ/embeds.md): Adding market embeds to your Substack or website.
- [How Do I Export My Key?](https://docs.polymarket.com/polymarket-learn/FAQ/how-to-export-private-key.md): Exporting your private key on Magic.Link
- [Is My Money Safe?](https://docs.polymarket.com/polymarket-learn/FAQ/is-my-money-safe.md): Yes. Polymarket is non-custodial, so you're in control of your funds.
- [Is Polymarket The House?](https://docs.polymarket.com/polymarket-learn/FAQ/is-polymarket-the-house.md): No, Polymarket is not the house. All trades happen peer-to-peer (p2p).
- [Polymarket vs. Polling](https://docs.polymarket.com/polymarket-learn/FAQ/polling.md): How is Polymarket better than traditional / legacy polling?
- [Recover Missing Deposit](https://docs.polymarket.com/polymarket-learn/FAQ/recover-missing-deposit.md): If you deposited the wrong cryptocurrency on Ethereum or Polygon, use these tools to recover those funds.
- [Can I Sell Early?](https://docs.polymarket.com/polymarket-learn/FAQ/sell-early.md)
- [How Do I Contact Support?](https://docs.polymarket.com/polymarket-learn/FAQ/support.md): Polymarket offers technical support through our website chat feature, and through Discord.
- [Does Polymarket Have a Token?](https://docs.polymarket.com/polymarket-learn/FAQ/wen-token.md)
- [What is a Prediction Market?](https://docs.polymarket.com/polymarket-learn/FAQ/what-are-prediction-markets.md): How people collectively forecast the future.
- [Why Crypto?](https://docs.polymarket.com/polymarket-learn/FAQ/why-do-i-need-crypto.md): Why Polymarket uses crypto and blockchain technology to create the worlds largest Prediction market.
- [Deposit with Coinbase](https://docs.polymarket.com/polymarket-learn/deposits/coinbase.md): How to buy and deposit USDC to your Polymarket account using Coinbase.
- [How to Withdraw](https://docs.polymarket.com/polymarket-learn/deposits/how-to-withdraw.md): How to withdraw your cash balance from Polymarket.
- [Large Cross Chain Deposits](https://docs.polymarket.com/polymarket-learn/deposits/large-cross-chain-deposits.md)
- [Deposit Using Your Card](https://docs.polymarket.com/polymarket-learn/deposits/moonpay.md): Use MoonPay to deposit cash using your Visa, Mastercard, or bank account.
- [Deposit by Transfering Crypto](https://docs.polymarket.com/polymarket-learn/deposits/supported-tokens.md): Learn what Tokens and Chains are supported for deposit.
- [Deposit USDC on Ethereum](https://docs.polymarket.com/polymarket-learn/deposits/usdc-on-eth.md): How to deposit USDC on the Ethereum Network to your Polymarket account.
- [How to Deposit](https://docs.polymarket.com/polymarket-learn/get-started/how-to-deposit.md): How to add cash to your balance on Polymarket.
- [How to Sign-Up](https://docs.polymarket.com/polymarket-learn/get-started/how-to-signup.md): How to create a Polymarket account.
- [Making Your First Trade](https://docs.polymarket.com/polymarket-learn/get-started/making-your-first-trade.md): How to buy shares.
- [What is Polymarket?](https://docs.polymarket.com/polymarket-learn/get-started/what-is-polymarket.md)
- [How Are Markets Disputed?](https://docs.polymarket.com/polymarket-learn/markets/dispute.md)
- [How Are Markets Clarified?](https://docs.polymarket.com/polymarket-learn/markets/how-are-markets-clarified.md): How are markets on Polymarket clarified?
- [How Are Markets Created?](https://docs.polymarket.com/polymarket-learn/markets/how-are-markets-created.md): Markets are created by the markets team with input from users and the community.
- [How Are Prediction Markets Resolved?](https://docs.polymarket.com/polymarket-learn/markets/how-are-markets-resolved.md): Markets are resolved by the UMA Optimistic Oracle, a smart-contract based optimistic oracle.
- [Trading Fees](https://docs.polymarket.com/polymarket-learn/trading/fees.md)
- [Holding Rewards](https://docs.polymarket.com/polymarket-learn/trading/holding-rewards.md)
- [How Are Prices Calculated?](https://docs.polymarket.com/polymarket-learn/trading/how-are-prices-calculated.md): The prices probabilities displayed on Polymarket are the midpoint of the bid-ask spread in the orderbook.
- [Limit Orders](https://docs.polymarket.com/polymarket-learn/trading/limit-orders.md): What are limit orders and how to make them.
- [Liquidity Rewards](https://docs.polymarket.com/polymarket-learn/trading/liquidity-rewards.md): Learn how to earn rewards merely by placing trades on Polymarket
- [Market Orders](https://docs.polymarket.com/polymarket-learn/trading/market-orders.md): How to buy shares.
- [Does Polymarket Have Trading Limits?](https://docs.polymarket.com/polymarket-learn/trading/no-limits.md)
- [Using the Order Book](https://docs.polymarket.com/polymarket-learn/trading/using-the-orderbook.md): Understanding the Order Book will help you become an advanced trader.
- [Glossary](https://docs.polymarket.com/quickstart/introduction/definitions.md)
- [Developer Quickstart](https://docs.polymarket.com/quickstart/introduction/main.md)
- [API Rate Limits](https://docs.polymarket.com/quickstart/introduction/rate-limits.md)
- [Your First Order](https://docs.polymarket.com/quickstart/orders/first-order.md)
- [WSS Quickstart](https://docs.polymarket.com/quickstart/websocket/WSS-Quickstart.md)
## Optional
- [Polymarket](https://polymarket.com)
- [Discord Community](https://discord.gg/polymarket)
- [Twitter](https://x.com/polymarket)
-540
View File
@@ -1,540 +0,0 @@
# Polymarket - Other
**Pages:** 7
---
## Deployment and Additional Information
**URL:** llms-txt#deployment-and-additional-information
**Contents:**
- Deployment
- Resources
Source: https://docs.polymarket.com/developers/CTF/deployment-resources
The CTF contract is deployed (and verified) at the following addresses:
| Network | Deployed Address |
| --------------- | ------------------------------------------------------------------------------------------------------------------------ |
| Polygon Mainnet | [0x4D97DCd97eC945f40cF65F87097ACe5EA0476045](https://polygonscan.com/address/0x4D97DCd97eC945f40cF65F87097ACe5EA0476045) |
| Polygon Mainnet | [0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E](https://polygonscan.com/address/0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E) |
Polymarket provides code samples in both Python and TypeScript for interacting
with our smart chain contracts. You will need an RPC endpoint to access the
blockchain, and you'll be responsible for paying gas fees when executing these
RPC/function calls. Please ensure you're using the correct example for your wallet
type (Safe Wallet vs Proxy Wallet) when implementing.
* [On-Chain Code Samples](https://github.com/Polymarket/examples/tree/main/examples)
* [Polygon RPC List](https://chainlist.org/chain/137)
* [CTF Source Code](https://github.com/gnosis/conditional-tokens-contracts)
* [Audits](https://github.com/gnosis/conditional-tokens-contracts/tree/master/docs/audit)
* [Gist For positionId Calculation](https://gist.github.com/L-Kov/950bce141a9d1aa1ed3b1cfce6d30217)
---
## Gamma Structure
**URL:** llms-txt#gamma-structure
Source: https://docs.polymarket.com/developers/gamma-markets-api/gamma-structure
Gamma provides some organizational models. These include events, and markets. The most fundamental element is always markets and the other models simply provide additional organization.
---
## Real Time Data Socket
**URL:** llms-txt#real-time-data-socket
**Contents:**
- Overview
- Connection Details
- Authentication
- Connection Management
- Available Subscription Types
- Message Structure
- Subscription Management
- Subscribe to Topics
- Unsubscribe from Topics
- Error Handling
Source: https://docs.polymarket.com/developers/RTDS/RTDS-overview
The Polymarket Real-Time Data Socket (RTDS) is a WebSocket-based streaming service that provides real-time updates for various Polymarket data streams. The service allows clients to subscribe to multiple data feeds simultaneously and receive live updates as events occur on the platform.
<Note>Polymarket provides a Typescript client for interacting with this streaming service. [Download and view it's documentation here](https://github.com/Polymarket/real-time-data-client)</Note>
### Connection Details
* **WebSocket URL**: `wss://ws-live-data.polymarket.com`
* **Protocol**: WebSocket
* **Data Format**: JSON
The RTDS supports two types of authentication depending on the subscription type:
1. **CLOB Authentication**: Required for certain trading-related subscriptions
* `key`: API key
* `secret`: API secret
* `passphrase`: API passphrase
2. **Gamma Authentication**: Required for user-specific data
* `address`: User wallet address
### Connection Management
The WebSocket connection supports:
* **Dynamic Subscriptions**: Without disconnecting from the socket users can add, remove and modify topics and filters they are subscribed to.
* **Ping/Pong**: You should send PING messages (every 5 seconds ideally) to maintain connection
## Available Subscription Types
<Note>Although this connection technically supports additional activity and subscription types, they are not fully supported at this time. Users are free to use them but there may be some unexpected behavior.</Note>
The RTDS currently supports the following subscription types:
1. **[Crypto Prices](/developers/RTDS/RTDS-crypto-prices)** - Real-time cryptocurrency price updates
2. **[Comments](/developers/RTDS/RTDS-comments)** - Comment-related events including reactions
All messages received from the WebSocket follow this structure:
* `topic`: The subscription topic (e.g., "crypto\_prices", "comments", "activity")
* `type`: The message type/event (e.g., "update", "reaction\_created", "orders\_matched")
* `timestamp`: Unix timestamp in milliseconds
* `payload`: Event-specific data object
## Subscription Management
### Subscribe to Topics
To subscribe to data streams, send a JSON message with this structure:
### Unsubscribe from Topics
To unsubscribe from data streams, send a similar message with `"action": "unsubscribe"`.
* Connection errors will trigger automatic reconnection attempts
* Invalid subscription messages may result in connection closure
* Authentication failures will prevent successful subscription to protected topics
**Examples:**
Example 1 (unknown):
```unknown
* `topic`: The subscription topic (e.g., "crypto\_prices", "comments", "activity")
* `type`: The message type/event (e.g., "update", "reaction\_created", "orders\_matched")
* `timestamp`: Unix timestamp in milliseconds
* `payload`: Event-specific data object
## Subscription Management
### Subscribe to Topics
To subscribe to data streams, send a JSON message with this structure:
```
---
## RTDS Crypto Prices
**URL:** llms-txt#rtds-crypto-prices
**Contents:**
- Overview
- Binance Source (`crypto_prices`)
- Subscription Details
- Subscription Message
- With Symbol Filter
- Chainlink Source (`crypto_prices_chainlink`)
- Subscription Details
- Subscription Message
- With Symbol Filter
- Message Format
Source: https://docs.polymarket.com/developers/RTDS/RTDS-crypto-prices
<Note>Polymarket provides a Typescript client for interacting with this streaming service. [Download and view it's documentation here](https://github.com/Polymarket/real-time-data-client)</Note>
The crypto prices subscription provides real-time updates for cryptocurrency price data from two different sources:
* **Binance Source** (`crypto_prices`): Real-time price data from Binance exchange
* **Chainlink Source** (`crypto_prices_chainlink`): Price data from Chainlink oracle networks
Both streams deliver current market prices for various cryptocurrency trading pairs, but use different symbol formats and subscription structures.
## Binance Source (`crypto_prices`)
### Subscription Details
* **Topic**: `crypto_prices`
* **Type**: `update`
* **Authentication**: Not required
* **Filters**: Optional (specific symbols can be filtered)
* **Symbol Format**: Lowercase concatenated pairs (e.g., `solusdt`, `btcusdt`)
### Subscription Message
### With Symbol Filter
To subscribe to specific cryptocurrency symbols, include a filters parameter:
## Chainlink Source (`crypto_prices_chainlink`)
### Subscription Details
* **Topic**: `crypto_prices_chainlink`
* **Type**: `*` (all types)
* **Authentication**: Not required
* **Filters**: Optional (JSON object with symbol specification)
* **Symbol Format**: Slash-separated pairs (e.g., `eth/usd`, `btc/usd`)
### Subscription Message
### With Symbol Filter
To subscribe to specific cryptocurrency symbols, include a JSON filters parameter:
### Binance Source Message Format
When subscribed to Binance crypto prices (`crypto_prices`), you'll receive messages with the following structure:
### Chainlink Source Message Format
When subscribed to Chainlink crypto prices (`crypto_prices_chainlink`), you'll receive messages with the following structure:
| Field | Type | Description |
| ----------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `symbol` | string | Trading pair symbol<br />**Binance**: lowercase concatenated (e.g., "solusdt", "btcusdt")<br />**Chainlink**: slash-separated (e.g., "eth/usd", "btc/usd") |
| `timestamp` | number | Price timestamp in Unix milliseconds |
| `value` | number | Current price value in the quote currency |
### Binance Source Examples
#### Solana Price Update (Binance)
#### Bitcoin Price Update (Binance)
### Chainlink Source Examples
#### Ethereum Price Update (Chainlink)
#### Bitcoin Price Update (Chainlink)
### Binance Source Symbols
The Binance source supports various cryptocurrency trading pairs using lowercase concatenated format:
* `btcusdt` - Bitcoin to USDT
* `ethusdt` - Ethereum to USDT
* `solusdt` - Solana to USDT
* `xrpusdt` - XRP to USDT
### Chainlink Source Symbols
The Chainlink source supports cryptocurrency trading pairs using slash-separated format:
* `btc/usd` - Bitcoin to USD
* `eth/usd` - Ethereum to USD
* `sol/usd` - Solana to USD
* `xrp/usd` - XRP to USD
* Price updates are sent as market prices change
* The timestamp in the payload represents when the price was recorded
* The outer timestamp represents when the message was sent via WebSocket
* No authentication is required for crypto price data
**Examples:**
Example 1 (unknown):
```unknown
### With Symbol Filter
To subscribe to specific cryptocurrency symbols, include a filters parameter:
```
Example 2 (unknown):
```unknown
## Chainlink Source (`crypto_prices_chainlink`)
### Subscription Details
* **Topic**: `crypto_prices_chainlink`
* **Type**: `*` (all types)
* **Authentication**: Not required
* **Filters**: Optional (JSON object with symbol specification)
* **Symbol Format**: Slash-separated pairs (e.g., `eth/usd`, `btc/usd`)
### Subscription Message
```
Example 3 (unknown):
```unknown
### With Symbol Filter
To subscribe to specific cryptocurrency symbols, include a JSON filters parameter:
```
Example 4 (unknown):
```unknown
## Message Format
### Binance Source Message Format
When subscribed to Binance crypto prices (`crypto_prices`), you'll receive messages with the following structure:
```
---
## RTDS Comments
**URL:** llms-txt#rtds-comments
**Contents:**
- Overview
- Subscription Details
- Subscription Message
- Message Format
- Message Types
- comment\_created
- comment\_removed
- reaction\_created
- reaction\_removed
- Payload Fields
Source: https://docs.polymarket.com/developers/RTDS/RTDS-comments
<Note>Polymarket provides a Typescript client for interacting with this streaming service. [Download and view it's documentation here](https://github.com/Polymarket/real-time-data-client)</Note>
The comments subscription provides real-time updates for comment-related events on the Polymarket platform. This includes new comments being created, as well as other comment interactions like reactions and replies.
## Subscription Details
* **Topic**: `comments`
* **Type**: `comment_created` (and potentially other comment event types like `reaction_created`)
* **Authentication**: May require Gamma authentication for user-specific data
* **Filters**: Optional (can filter by specific comment IDs, users, or events)
## Subscription Message
When subscribed to comments, you'll receive messages with the following structure:
Triggered when a user creates a new comment on an event or in reply to another comment.
Triggered when a comment is removed or deleted.
### reaction\_created
Triggered when a user adds a reaction to an existing comment.
### reaction\_removed
Triggered when a reaction is removed from a comment.
| Field | Type | Description |
| ------------------ | ------ | ------------------------------------------------------------------------- |
| `body` | string | The text content of the comment |
| `createdAt` | string | ISO 8601 timestamp when the comment was created |
| `id` | string | Unique identifier for this comment |
| `parentCommentID` | string | ID of the parent comment if this is a reply (null for top-level comments) |
| `parentEntityID` | number | ID of the parent entity (event, market, etc.) |
| `parentEntityType` | string | Type of parent entity (e.g., "Event", "Market") |
| `profile` | object | Profile information of the user who created the comment |
| `reactionCount` | number | Current number of reactions on this comment |
| `replyAddress` | string | Polygon address for replies (may be different from userAddress) |
| `reportCount` | number | Current number of reports on this comment |
| `userAddress` | string | Polygon address of the user who created the comment |
### Profile Object Fields
| Field | Type | Description |
| ----------------------- | ------- | ------------------------------------------------- |
| `baseAddress` | string | User profile address |
| `displayUsernamePublic` | boolean | Whether the username should be displayed publicly |
| `name` | string | User's display name |
| `proxyWallet` | string | Proxy wallet address used for transactions |
| `pseudonym` | string | Generated pseudonym for the user |
## Parent Entity Types
The following parent entity types are supported:
* `Event` - Comments on prediction events
* `Market` - Comments on specific markets
* Additional entity types may be available
### New Comment Created
### Reply to Existing Comment
Comments support nested threading:
* **Top-level comments**: `parentCommentID` is null or empty
* **Reply comments**: `parentCommentID` contains the ID of the parent comment
* All comments are associated with a `parentEntityID` and `parentEntityType`
* Real-time comment feed displays
* Discussion thread monitoring
* Community sentiment analysis
* Comments include `reactionCount` and `reportCount`
* Comment body contains the full text content
* The `createdAt` timestamp uses ISO 8601 format with timezone information
* The outer `timestamp` field represents when the WebSocket message was sent
* User profiles include both primary addresses and proxy wallet addresses
**Examples:**
Example 1 (unknown):
```unknown
## Message Format
When subscribed to comments, you'll receive messages with the following structure:
```
Example 2 (unknown):
```unknown
## Message Types
### comment\_created
Triggered when a user creates a new comment on an event or in reply to another comment.
### comment\_removed
Triggered when a comment is removed or deleted.
### reaction\_created
Triggered when a user adds a reaction to an existing comment.
### reaction\_removed
Triggered when a reaction is removed from a comment.
## Payload Fields
| Field | Type | Description |
| ------------------ | ------ | ------------------------------------------------------------------------- |
| `body` | string | The text content of the comment |
| `createdAt` | string | ISO 8601 timestamp when the comment was created |
| `id` | string | Unique identifier for this comment |
| `parentCommentID` | string | ID of the parent comment if this is a reply (null for top-level comments) |
| `parentEntityID` | number | ID of the parent entity (event, market, etc.) |
| `parentEntityType` | string | Type of parent entity (e.g., "Event", "Market") |
| `profile` | object | Profile information of the user who created the comment |
| `reactionCount` | number | Current number of reactions on this comment |
| `replyAddress` | string | Polygon address for replies (may be different from userAddress) |
| `reportCount` | number | Current number of reports on this comment |
| `userAddress` | string | Polygon address of the user who created the comment |
### Profile Object Fields
| Field | Type | Description |
| ----------------------- | ------- | ------------------------------------------------- |
| `baseAddress` | string | User profile address |
| `displayUsernamePublic` | boolean | Whether the username should be displayed publicly |
| `name` | string | User's display name |
| `proxyWallet` | string | Proxy wallet address used for transactions |
| `pseudonym` | string | Generated pseudonym for the user |
## Parent Entity Types
The following parent entity types are supported:
* `Event` - Comments on prediction events
* `Market` - Comments on specific markets
* Additional entity types may be available
## Example Messages
### New Comment Created
```
Example 3 (unknown):
```unknown
### Reply to Existing Comment
```
---
## UMA Optimistic Oracle Integration
**URL:** llms-txt#uma-optimistic-oracle-integration
**Contents:**
- Overview
- Clarifications
- Resolution Process
- Actions
- Possible Flows
- Deployed Addresses
- v3.0
- v2.0
- v1.0
- Additional Resources
Polymarket leverages UMA's Optimistic Oracle (OO) to resolve arbitrary questions, permissionlessly. From [UMA's docs](https://docs.uma.xyz/protocol-overview/how-does-umas-oracle-work):
"UMA's Optimistic Oracle allows contracts to quickly request and receive data information ... The Optimistic Oracle acts as a generalized escalation game between contracts that initiate a price request and UMA's dispute resolution system known as the Data Verification Mechanism (DVM). Prices proposed by the Optimistic Oracle will not be sent to the DVM unless it is disputed. If a dispute is raised, a request is sent to the DVM. All contracts built on UMA use the DVM as a backstop to resolve disputes. Disputes sent to the DVM will be resolved within a few days -- after UMA tokenholders vote on what the correct outcome should have been."
To allow CTF markets to be resolved via the OO, Polymarket developed a custom adapter contract called `UmaCtfAdapter` that provides a way for the two contract systems to interface.
Recent versions (v2+) of the `UmaCtfAdapter` also include a bulletin board feature that allows market creators to issue "clarifications". Questions that allow updates will include the sentence in their ancillary data:
"Updates made by the question creator via the bulletin board on 0x6A5D0222186C0FceA7547534cC13c3CFd9b7b6A4F74 should be considered. In summary, clarifications that do not impact the question's intent should be considered."
Where the [transaction](https://polygonscan.com/tx/0xa14f01b115c4913624fc3f508f960f4dea252758e73c28f5f07f8e19d7bca066) reference outlining what outlining should be considered.
## Resolution Process
* **Initiate** - Binary CTF markets are initialized via the `UmaCtfAdapter`'s `initialize()` function. This stores the question parameters on the contract, prepares the CTF and requests a price for a question from the OO. It returns a `questionID` that is also used to reference on the `UmaCtfAdapter`. The caller provides:
1. `ancillaryData` - data used to resolve a question (i.e the question + clarifications)
2. `rewardToken` - ERC20 token address used for payment of rewards and fees
3. `reward` - Reward amount offered to a successful proposer. The caller must have set allowance so that the contract can pull this reward in.
4. `proposalBond` - Bond required to be posted by OO proposers/disputers. If 0, the default OO bond is used.
5. `liveness` - UMA liveness period in seconds. If 0, the default liveness period is used.
* **Propose Price** - Anyone can then propose a price to the question on the OO. To do this they must post the `proposalBond`. The liveness period begins after a price is proposed.
* **Dispute** - Anyone that disagrees with the proposed price has the opportunity to dispute the price by posting a counter bond via the OO, this proposed will now be escalated to the DVM for a voter-wide vote.
When the first proposed price is disputed for a `questionID` on the adapter, a callback is made and posted as the reward for this new proposal. This means a second `questionID`, making a new `questionID` to the OO (the reward is returned before the callback is made and posted as the reward for this new proposal). This allows for a second round of resolution, and correspondingly a second dispute is required for it to go to the DVM. The thinking behind this is to doubles the cost of a potential griefing vector (two disputes are required just one) and also allows far-fetched (incorrect) first price proposals to not delay the resolution. As such there are two possible flows:
* **Initialize (CTFAdapter) -> Propose (OO) -> Resolve (CTFAdapter)**
* **Initialize (CTFAdaptor) -> Propose (OO) -> Challenge (OO) -> Propose (OO) -> Resolve (CTFAdaptor)**
* **Initialize (CTFAdaptor) -> Propose (OO) -> Challenge (OO) -> Propose (OO) -> Challenge (CtfAdapter) -> Resolve (CTFAdaptor)**
## Deployed Addresses
| Network | Address |
| --------------- | ------------------------------------------------------------------------------------------------------------------------ |
| Polygon Mainnet | [0x2F5e3684cb1F318ec51b00Edba38d79Ac2c0aA9d](https://polygonscan.com/address/0x2F5e3684cb1F318ec51b00Edba38d79Ac2c0aA9d) |
| Network | Address |
| --------------- | --------------------------------------------------------------------------------------------------------------------------- |
| Polygon Mainnet | [0x6A9D0222186C0FceA7547534cC13c3CFd9b7b6A4F74](https://polygonscan.com/address/0x6A9D222616C90FcA5754cd1333cFD9b7fb6a4F74) |
| Network | Address |
| --------------- | -------------------------------------------------------------------------------------------------------------------------- |
| Polygon Mainnet | [0xC8B122858a4EF82C2d4eE2E6A276C719e692995130](https://polygonscan.com/address/0xCB1822859cEF82Cd2Eb4E6276C7916e692995130) |
## Additional Resources
* [Audit](https://github.com/Polymarket/uma-ctf-adapter/blob/main/audit/Polymarket_UMA_Optimistic_Oracle_Adapter_Audit.pdf)
* [Source Code](https://github.com/Polymarket/uma-ctf-adapter)
* [UMA Documentation](https://docs.uma.xyz/)
* [UMA Oracle Portal](https://oracle.uma.xyz/)
---
## Resolution
**URL:** llms-txt#resolution
Source: https://docs.polymarket.com/developers/resolution/UMA
---
@@ -1,396 +0,0 @@
# Real time data client
This client provides a wrapper to connect to the `real-time-data-streaming` `WebSocket` service.
## How to use it
Here is a quick example about how to connect to the service and start receiving messages (you can find more in the folder `examples/`):
```typescript
import { RealTimeDataClient } from "../src/client";
import { Message } from "../src/model";
const onMessage = (message: Message): void => {
console.log(message.topic, message.type, message.payload);
};
const onConnect = (client: RealTimeDataClient): void => {
// Subscribe to a topic
client.subscribe({
subscriptions: [
{
topic: "comments",
type: "*", // "*"" can be used to connect to all the types of the topic
filters: `{"parentEntityID":100,"parentEntityType":"Event"}`, // empty means no filter
},
],
});
};
new RealTimeDataClient({ onMessage, onConnect }).connect();
```
## How to subscribe and unsubscribe from messages
Once the connection is stablished and you have a `client: RealTimeDataClient` object, you can `subscribe` and `unsubscribe` to many messages streamings using the same connection.
### Subscribe
Subscribe to 'trades' messages from the topic 'activity' and to the all comments messages.
```typescript
client.subscribe({
subscriptions: [
{
topic: "activity",
type: "trades",
},
],
});
client.subscribe({
subscriptions: [
{
topic: "comments",
type: "*", // "*"" can be used to connect to all the types of the topic
},
],
});
```
### Unsubscribe
Unsubscribe from the new trades messages of the topic 'activity'. If 'activity' has more messages types and I used '\*' to connect to all of them, this will only unsubscribe from the type 'trades'.
```typescript
client.subscribe({
subscriptions: [
{
topic: "activity",
type: "trades",
},
],
});
```
### Disconnect
The `client` object provides a method to disconnect from the `WebSocket` server:
```typescript
client.disconnect();
```
## Messages hierarchy
| Topic | Type | Auth | Filters (if it is empty the messages won't be filtered) | Schema | Subscription Handler |
| ------------------------- | ------------------ | -------- | --------------------------------------------------------------- | ----------------------------------- | ----------------------------------------------------------- |
| `activity` | `trades` | - | `{"event_slug":"string"}' OR '{"market_slug":"string"}` | [`Trade`](#trade) | |
| `activity` | `orders_matched` | - | `{"event_slug":"string"}' OR '{"market_slug":"string"}` | [`Trade`](#trade) | |
| `comments` | `comment_created` | - | `{"parentEntityID":number,"parentEntityType":"Event / Series"}` | [`Comment`](#comment) | |
| `comments` | `comment_removed` | - | `{"parentEntityID":number,"parentEntityType":"Event / Series"}` | [`Comment`](#comment) | |
| `comments` | `reaction_created` | - | `{"parentEntityID":number,"parentEntityType":"Event / Series"}` | [`Reaction`](#reaction) | |
| `comments` | `reaction_removed` | - | `{"parentEntityID":number,"parentEntityType":"Event / Series"}` | [`Reaction`](#reaction) | |
| `rfq` | `request_created` | - | - | [`Request`](#request) | |
| `rfq` | `request_edited` | - | - | [`Request`](#request) | |
| `rfq` | `request_canceled` | - | - | [`Request`](#request) | |
| `rfq` | `request_expired` | - | - | [`Request`](#request) | |
| `rfq` | `quote_created` | - | - | [`Quote`](#quote) | |
| `rfq` | `quote_edited` | - | - | [`Quote`](#quote) | |
| `rfq` | `quote_canceled` | - | - | [`Quote`](#quote) | |
| `rfq` | `quote_expired` | - | - | [`Quote`](#quote) | |
| `crypto_prices` | `update` | - | `{"symbol":string}` | [`CryptoPrice`](#cryptoprice) | [`CryptoPriceHistorical`](#initial-data-dump-on-connection) |
| `crypto_prices_chainlink` | `update` | - | `{"symbol":string}` | [`CryptoPrice`](#cryptoprice) | [`CryptoPriceHistorical`](#initial-data-dump-on-connection) |
| `clob_user` | `order` | ClobAuth | - | [`Order`](#order) | |
| `clob_user` | `trade` | ClobAuth | - | [`Trade`](#trade-1) | |
| `clob_market` | `price_change` | - | `["100","200",...]` (filters are mandatory on this one) | [`PriceChanges`](#pricechanges) | |
| `clob_market` | `agg_orderbook` | - | `["100","200",...]` | [`AggOrderbook`](#aggorderbook) | [`AggOrderbook`](#aggorderbook) |
| `clob_market` | `last_trade_price` | - | `["100","200",...]` | [`LastTradePrice`](#lasttradeprice) | |
| `clob_market` | `tick_size_change` | - | `["100","200",...]` | [`TickSizeChange`](#ticksizechange) | |
| `clob_market` | `market_created` | - | - | [`ClobMarket`](#clobmarket) | |
| `clob_market` | `market_resolved` | - | - | [`ClobMarket`](#clobmarket) | |
## Auth
### ClobAuth
```typescript
/**
* API key credentials for CLOB authentication.
*/
export interface ClobApiKeyCreds {
/** API key used for authentication */
key: string;
/** API secret associated with the key */
secret: string;
/** Passphrase required for authentication */
passphrase: string;
}
```
```typescript
client.subscribe({
subscriptions: [
{
topic: "clob_user",
type: "*",
clob_auth: {
key: "xxxxxx-xxxx-xxxxx-xxxx-xxxxxx",
secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
passphrase: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
},
},
],
});
```
## Message types
### Activity
#### Trade
| Name | Type | Description |
| ----------------- | ------- | -------------------------------------------------- |
| `asset` | string | ERC1155 token ID of conditional token being traded |
| `bio` | string | Bio of the user of the trade |
| `conditionId` | string | Id of market which is also the CTF condition ID |
| `eventSlug` | string | Slug of the event |
| `icon` | string | URL to the market icon image |
| `name` | string | Name of the user of the trade |
| `outcome` | string | Human readable outcome of the market |
| `outcomeIndex` | integer | Index of the outcome |
| `price` | float | Price of the trade |
| `profileImage` | string | URL to the user profile image |
| `proxyWallet` | string | Address of the user proxy wallet |
| `pseudonym` | string | Pseudonym of the user |
| `side` | string | Side of the trade (`BUY`/`SELL`) |
| `size` | integer | Size of the trade |
| `slug` | string | Slug of the market |
| `timestamp` | integer | Timestamp of the trade |
| `title` | string | Title of the event |
| `transactionHash` | string | Hash of the transaction |
### Comments
#### Comment
| Name | Type | Description |
| ------------------ | ------ | ------------------------------------------- |
| `id` | string | Unique identifier of comment |
| `body` | string | Content of the comment |
| `parentEntityType` | string | Type of the parent entity (Event or Series) |
| `parentEntityID` | number | ID of the parent entity |
| `parentCommentID` | string | ID of the parent comment |
| `userAddress` | string | Address of the user |
| `replyAddress` | string | Address of the reply user |
| `createdAt` | string | Creation timestamp |
| `updatedAt` | string | Last update timestamp |
#### Reaction
| Name | Type | Description |
| -------------- | ------ | ------------------------------ |
| `id` | string | Unique identifier of reaction |
| `commentID` | number | ID of the comment |
| `reactionType` | string | Type of the reaction |
| `icon` | string | Icon representing the reaction |
| `userAddress` | string | Address of the user |
| `createdAt` | string | Creation timestamp |
### RFQ
#### Request
| Name | Type | Description |
| -------------- | ------ | --------------------------------------------------------------- |
| `requestId` | string | Unique identifier for the request |
| `proxyAddress` | string | User proxy address |
| `market` | string | Id of market which is also the CTF condition ID |
| `token` | string | `ERC1155` token ID of conditional token being traded |
| `complement` | string | Complement `ERC1155` token ID of conditional token being traded |
| `state` | string | Current state of the request |
| `side` | string | Indicates buy or sell side |
| `sizeIn` | number | Input size of the request |
| `sizeOut` | number | Output size of the request |
| `price` | number | Price from in/out sizes |
| `expiry` | number | Expiry timestamp (UNIX format) |
#### Quote
| Name | Type | Description |
| -------------- | ------ | --------------------------------------------------------------- |
| `quoteId` | string | Unique identifier for the quote |
| `requestId` | string | Associated request identifier |
| `proxyAddress` | string | User proxy address |
| `token` | string | `ERC1155` token ID of conditional token being traded |
| `state` | string | Current state of the quote |
| `side` | string | Indicates buy or sell side |
| `sizeIn` | number | Input size of the quote |
| `sizeOut` | number | Output size of the quote |
| `sizeOut` | number | Output size of the request |
| `condition` | string | Id of market which is also the CTF condition ID |
| `complement` | string | Complement `ERC1155` token ID of conditional token being traded |
| `expiry` | number | Expiry timestamp (UNIX format) |
### CryptoPrice
| Name | Type | Description |
| ----------- | ------ | ---------------------------------------- |
| `symbol` | string | Symbol of the asset |
| `timestamp` | number | Timestamp in milliseconds for the update |
| `value` | number | Value at the time of update |
#### Filters
- `{"symbol":"btcusdt"}`
- `{"symbol":"ethusdt"}`
- `{"symbol":"xrpusdt"}`
- `{"symbol":"solusdt"}`
#### Initial data dump on connection
When the connection is stablished, if a `filter` is used, the server will dump an initial snapshoot of recent data
| Name | Type | Description |
| ------ | ------ | ---------------------------------------------------------------- |
| symbol | string | Symbol of the asset |
| data | array | Array of price data objects, each containing timestamp and value |
### CLOB User
#### Order
| Name | Type | Description |
| --------------- | ------------------ | --------------------------------------------------------- |
| `asset_id` | string | Order's `ERC1155` token ID of conditional token |
| `created_at` | string (timestamp) | Order's creation UNIX timestamp |
| `expiration` | string (timestamp) | Order's expiration UNIX timestamp |
| `id` | string | Unique order hash identifier |
| `maker_address` | string | Makers address (funder) |
| `market` | string | Condition ID or market identifier |
| `order_type` | string | Type of order: `GTC`, `GTD`, `FOK`, `FAK` |
| `original_size` | string | Original size of the order at placement |
| `outcome` | string | Order outcome: `YES` / `NO` |
| `owner` | string | UUID of the order owner |
| `price` | string | Order price (e.g., in decimals like `0.5`) |
| `side` | string | Side of the trade: `BUY` or `SELL` |
| `size_matched` | string | Amount of order that has been matched |
| `status` | string | Status of the order (e.g., `MATCHED`) |
| `type` | string | Type of update: `PLACEMENT`, `CANCELLATION`, `FILL`, etc. |
#### Trade
| Name | Type | Description |
| ------------------ | ------------------ | ----------------------------------------------------------------- |
| `asset_id` | string | `ERC1155` token ID of the conditional token involved in the trade |
| `fee_rate_bps` | string | Fee rate in basis points (bps) |
| `id` | string | Unique identifier for the match record |
| `last_update` | string (timestamp) | Last update timestamp (UNIX) |
| `maker_address` | string | Makers address |
| `maker_orders` | array | List of maker orders (see nested schema below) |
| `market` | string | Condition ID or market identifier |
| `match_time` | string (timestamp) | Match execution timestamp (UNIX) |
| `outcome` | string | Outcome of the market: `YES` / `NO` |
| `owner` | string | UUID of the taker (owner of the matched order) |
| `price` | string | Matched price (in decimal format, e.g., `0.5`) |
| `side` | string | Taker side of the trade: `BUY` or `SELL` |
| `size` | string | Total matched size |
| `status` | string | Status of the match: e.g., `MINED` |
| `taker_order_id` | string | ID of the taker's order |
| `transaction_hash` | string | Transaction hash where the match was settled |
##### `maker_orders`
| Name | Type | Description |
| ---------------- | ------ | ---------------------------------------------------------------- |
| `asset_id` | string | `ERC1155` token ID of the conditional token of the maker's order |
| `fee_rate_bps` | string | Maker's fee rate in basis points |
| `maker_address` | string | Makers address |
| `matched_amount` | string | Amount matched from the maker's order |
| `order_id` | string | ID of the maker's order |
| `outcome` | string | Outcome targeted by the maker's order (`YES` / `NO`) |
| `owner` | string | UUID of the maker |
| `price` | string | Order price |
| `side` | string | Side of the maker: `BUY` or `SELL` |
### CLOB market
#### PriceChanges
| Name | Type | Description |
| ------------------- | ------------------ | --------------------------------------------------------- |
| `m` (market) | string | Condition ID |
| `pc` (price change) | array | Price changes by book |
| `t` (timestamp) | string (timestamp) | Timestamp in milliseconds since epoch (UNIX time \* 1000) |
##### PriceChange
NOTE: Filters are mandatory for this topic/type. Example: `["100","200",...]` (collection of token ids)
| Name | Type | Description |
| --------------- | ------ | --------------------------------------------------------------- |
| `a` (asset_id) | string | Asset identifier |
| `h` (hash) | string | Unique hash ID of the book snapshot |
| `p` (price) | string | Price quoted (e.g., `0.5`) |
| `s` (side) | string | Side of the quote: `BUY` or `SELL` |
| `si` (size) | string | Size or volume available at the quoted price (e.g., `0`, `100`) |
| `ba` (best_ask) | string | Best ask price |
| `bb` (best_bid) | string | Best bid price |
#### AggOrderbook
| Name | Type | Description |
| ---------------- | ------------------ | ----------------------------------------------------------------------- |
| `asks` | array | List of ask aggregated orders (sell side), each with `price` and `size` |
| `asset_id` | string | Asset Id identifier |
| `bids` | array | List of aggregated bid orders (buy side), each with `price` and `size` |
| `hash` | string | Unique hash ID for this orderbook snapshot |
| `market` | string | Market or condition ID |
| `min_order_size` | string | Minimum allowed order size |
| `neg_risk` | boolean | NegRisk or not |
| `tick_size` | string | Minimum tick size |
| `timestamp` | string (timestamp) | Timestamp in milliseconds since epoch (UNIX time \* 1000) |
##### `asks`/`bids` scheema
| Name | Type | Description |
| ------- | ------ | ------------------ |
| `price` | string | Price level |
| `size` | string | Size at that price |
##### Initial data dump on connection
When the connection is stablished, if a `filter` is used, the server will dump an initial snapshoot of recent data
#### LastTradePrice
| Name | Type | Description |
| -------------- | ------ | ---------------------------------- |
| `asset_id` | string | Asset Id identifier |
| `fee_rate_bps` | string | Fee rate in basis points (bps) |
| `market` | string | Market or condition ID |
| `price` | string | Trade price (e.g., `0.5`) |
| `side` | string | Side of the order: `BUY` or `SELL` |
| `size` | string | Size of the trade |
#### TickSizeChange
| Name | Type | Description |
| --------------- | ------ | ------------------------------------ |
| `market` | string | Market or condition ID |
| `asset_id` | string | Array of two `ERC1155` asset ID |
| `old_tick_size` | string | Previous tick size before the change |
| `new_tick_size` | string | Updated tick size after the change |
#### ClobMarket
| Name | Type | Description |
| ---------------- | --------- | ------------------------------------------------------------------ |
| `market` | string | Market or condition ID |
| `asset_ids` | [2]string | Array of two `ERC1155` asset ID identifiers associated with market |
| `min_order_size` | string | Minimum size allowed for an order |
| `tick_size` | string | Minimum allowable price increment |
| `neg_risk` | boolean | Indicates if the market is negative risk |
File diff suppressed because it is too large Load Diff