Update Polymarket documentation (2026-02-19)
- Added new documentation URLs from llms.txt index - Updated TARGET.md with 244 total documentation pages - Scraped new pages for trading, concepts, and API reference sections - Updated changelog and new index pages
This commit is contained in:
@@ -4,39 +4,37 @@
|
||||
|
||||
# Market Channel
|
||||
|
||||
Public channel for updates related to market updates (level 2 price data).
|
||||
> Real-time orderbook, price, and trade data
|
||||
|
||||
**SUBSCRIBE**
|
||||
Public channel for market data updates (level 2 price data). Subscribe with asset IDs to receive orderbook snapshots, price changes, trade executions, and market events.
|
||||
|
||||
`<wss-channel> market`
|
||||
## Endpoint
|
||||
|
||||
## book Message
|
||||
```
|
||||
wss://ws-subscriptions-clob.polymarket.com/ws/market
|
||||
```
|
||||
|
||||
Emitted When:
|
||||
## Subscription
|
||||
|
||||
* First subscribed to a market
|
||||
* When there is a trade that affects the book
|
||||
```json theme={null}
|
||||
{
|
||||
"assets_ids": ["<token_id_1>", "<token_id_2>"],
|
||||
"type": "market",
|
||||
"custom_feature_enabled": true
|
||||
}
|
||||
```
|
||||
|
||||
### Structure
|
||||
Set `custom_feature_enabled: true` to receive `best_bid_ask`, `new_market`, and `market_resolved` events.
|
||||
|
||||
| Name | Type | Description |
|
||||
| ----------- | --------------- | --------------------------------------------------------------------------- |
|
||||
| event\_type | string | "book" |
|
||||
| asset\_id | string | asset ID (token ID) |
|
||||
| market | string | condition ID of market |
|
||||
| timestamp | string | unix timestamp the current book generation in milliseconds (1/1,000 second) |
|
||||
| hash | string | hash summary of the orderbook content |
|
||||
| buys | OrderSummary\[] | list of type (size, price) aggregate book levels for buys |
|
||||
| sells | OrderSummary\[] | list of type (size, price) aggregate book levels for sells |
|
||||
## Message Types
|
||||
|
||||
Where a `OrderSummary` object is of the form:
|
||||
Each message includes an `event_type` field identifying the type.
|
||||
|
||||
| Name | Type | Description |
|
||||
| ----- | ------ | ---------------------------------- |
|
||||
| price | string | price of the orderbook level |
|
||||
| size | string | size available at that price level |
|
||||
### book
|
||||
|
||||
```json Response theme={null}
|
||||
Emitted when first subscribed to a market and when there is a trade that affects the book.
|
||||
|
||||
```json theme={null}
|
||||
{
|
||||
"event_type": "book",
|
||||
"asset_id": "65818619657568813474341868652308942079804919287380422192892211131408793125422",
|
||||
@@ -56,137 +54,79 @@ Where a `OrderSummary` object is of the form:
|
||||
}
|
||||
```
|
||||
|
||||
## price\_change Message
|
||||
### price\_change
|
||||
|
||||
<div style={{backgroundColor: '#fff3cd', border: '1px solid #ffeaa7', borderRadius: '4px', padding: '12px', marginBottom: '16px'}}>
|
||||
<strong>⚠️ Breaking Change Notice:</strong> The price\_change message schema will be updated on September 15, 2025 at 11 PM UTC. Please see the [migration guide](/developers/CLOB/websocket/market-channel-migration-guide) for details.
|
||||
</div>
|
||||
Emitted when a new order is placed or an order is cancelled.
|
||||
|
||||
Emitted When:
|
||||
|
||||
* A new order is placed
|
||||
* An order is cancelled
|
||||
|
||||
### Structure
|
||||
|
||||
| Name | Type | Description |
|
||||
| -------------- | -------------- | ------------------------------ |
|
||||
| event\_type | string | "price\_change" |
|
||||
| market | string | condition ID of market |
|
||||
| price\_changes | PriceChange\[] | array of price change objects |
|
||||
| timestamp | string | unix timestamp in milliseconds |
|
||||
|
||||
Where a `PriceChange` object is of the form:
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------- | ------ | ---------------------------------- |
|
||||
| asset\_id | string | asset ID (token ID) |
|
||||
| price | string | price level affected |
|
||||
| size | string | new aggregate size for price level |
|
||||
| side | string | "BUY" or "SELL" |
|
||||
| hash | string | hash of the order |
|
||||
| best\_bid | string | current best bid price |
|
||||
| best\_ask | string | current best ask price |
|
||||
|
||||
```json Response theme={null}
|
||||
```json theme={null}
|
||||
{
|
||||
"market": "0x5f65177b394277fd294cd75650044e32ba009a95022d88a0c1d565897d72f8f1",
|
||||
"price_changes": [
|
||||
{
|
||||
"asset_id": "71321045679252212594626385532706912750332728571942532289631379312455583992563",
|
||||
"price": "0.5",
|
||||
"size": "200",
|
||||
"side": "BUY",
|
||||
"hash": "56621a121a47ed9333273e21c83b660cff37ae50",
|
||||
"best_bid": "0.5",
|
||||
"best_ask": "1"
|
||||
},
|
||||
{
|
||||
"asset_id": "52114319501245915516055106046884209969926127482827954674443846427813813222426",
|
||||
"price": "0.5",
|
||||
"size": "200",
|
||||
"side": "SELL",
|
||||
"hash": "1895759e4df7a796bf4f1c5a5950b748306923e2",
|
||||
"best_bid": "0",
|
||||
"best_ask": "0.5"
|
||||
}
|
||||
],
|
||||
"timestamp": "1757908892351",
|
||||
"event_type": "price_change"
|
||||
"market": "0x5f65177b394277fd294cd75650044e32ba009a95022d88a0c1d565897d72f8f1",
|
||||
"price_changes": [
|
||||
{
|
||||
"asset_id": "71321045679252212594626385532706912750332728571942532289631379312455583992563",
|
||||
"price": "0.5",
|
||||
"size": "200",
|
||||
"side": "BUY",
|
||||
"hash": "56621a121a47ed9333273e21c83b660cff37ae50",
|
||||
"best_bid": "0.5",
|
||||
"best_ask": "1"
|
||||
},
|
||||
{
|
||||
"asset_id": "52114319501245915516055106046884209969926127482827954674443846427813813222426",
|
||||
"price": "0.5",
|
||||
"size": "200",
|
||||
"side": "SELL",
|
||||
"hash": "1895759e4df7a796bf4f1c5a5950b748306923e2",
|
||||
"best_bid": "0",
|
||||
"best_ask": "0.5"
|
||||
}
|
||||
],
|
||||
"timestamp": "1757908892351",
|
||||
"event_type": "price_change"
|
||||
}
|
||||
```
|
||||
|
||||
## tick\_size\_change Message
|
||||
A `size` of `"0"` means the price level has been removed from the book.
|
||||
|
||||
Emitted When:
|
||||
### tick\_size\_change
|
||||
|
||||
* The minimum tick size of the market changes. This happens when the book's price reaches the limits: price > 0.96 or price \< 0.04
|
||||
Emitted when the minimum tick size of a market changes. This happens when the book's price reaches the limits: price > 0.96 or price \< 0.04.
|
||||
|
||||
### Structure
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------------- | ------ | -------------------------- |
|
||||
| event\_type | string | "price\_change" |
|
||||
| asset\_id | string | asset ID (token ID) |
|
||||
| market | string | condition ID of market |
|
||||
| old\_tick\_size | string | previous minimum tick size |
|
||||
| new\_tick\_size | string | current minimum tick size |
|
||||
| side | string | buy/sell |
|
||||
| timestamp | string | time of event |
|
||||
|
||||
```json Response theme={null}
|
||||
```json theme={null}
|
||||
{
|
||||
"event_type": "tick_size_change",
|
||||
"asset_id": "65818619657568813474341868652308942079804919287380422192892211131408793125422",\
|
||||
"market": "0xbd31dc8a20211944f6b70f31557f1001557b59905b7738480ca09bd4532f84af",
|
||||
"old_tick_size": "0.01",
|
||||
"new_tick_size": "0.001",
|
||||
"timestamp": "100000000"
|
||||
"event_type": "tick_size_change",
|
||||
"asset_id": "65818619657568813474341868652308942079804919287380422192892211131408793125422",
|
||||
"market": "0xbd31dc8a20211944f6b70f31557f1001557b59905b7738480ca09bd4532f84af",
|
||||
"old_tick_size": "0.01",
|
||||
"new_tick_size": "0.001",
|
||||
"timestamp": "100000000"
|
||||
}
|
||||
```
|
||||
|
||||
## last\_trade\_price Message
|
||||
### last\_trade\_price
|
||||
|
||||
Emitted When:
|
||||
Emitted when a maker and taker order is matched, creating a trade event.
|
||||
|
||||
* When a maker and taker order is matched creating a trade event.
|
||||
|
||||
```json Response theme={null}
|
||||
```json theme={null}
|
||||
{
|
||||
"asset_id":"114122071509644379678018727908709560226618148003371446110114509806601493071694",
|
||||
"event_type":"last_trade_price",
|
||||
"fee_rate_bps":"0",
|
||||
"market":"0x6a67b9d828d53862160e470329ffea5246f338ecfffdf2cab45211ec578b0347",
|
||||
"price":"0.456",
|
||||
"side":"BUY",
|
||||
"size":"219.217767",
|
||||
"timestamp":"1750428146322"
|
||||
"asset_id": "114122071509644379678018727908709560226618148003371446110114509806601493071694",
|
||||
"event_type": "last_trade_price",
|
||||
"fee_rate_bps": "0",
|
||||
"market": "0x6a67b9d828d53862160e470329ffea5246f338ecfffdf2cab45211ec578b0347",
|
||||
"price": "0.456",
|
||||
"side": "BUY",
|
||||
"size": "219.217767",
|
||||
"timestamp": "1750428146322"
|
||||
}
|
||||
```
|
||||
|
||||
## best\_bid\_ask Message
|
||||
### best\_bid\_ask
|
||||
|
||||
Emitted When:
|
||||
<Note>Requires `custom_feature_enabled: true`.</Note>
|
||||
|
||||
* The best bid and ask prices for a market change.
|
||||
Emitted when the best bid or ask prices for a market change.
|
||||
|
||||
(This message is behind the `custom_feature_enabled` flag)
|
||||
|
||||
### Structure
|
||||
|
||||
| Name | Type | Description |
|
||||
| ----------- | ------ | ------------------------------- |
|
||||
| event\_type | string | "best\_bid\_ask" |
|
||||
| market | string | condition ID of market |
|
||||
| asset\_id | string | asset ID (token ID) |
|
||||
| best\_bid | string | current best bid price |
|
||||
| best\_ask | string | current best ask price |
|
||||
| spread | string | spread between best bid and ask |
|
||||
| timestamp | string | unix timestamp in milliseconds |
|
||||
|
||||
### Example
|
||||
|
||||
```json Response theme={null}
|
||||
```json theme={null}
|
||||
{
|
||||
"event_type": "best_bid_ask",
|
||||
"market": "0x0005c0d312de0be897668695bae9f32b624b4a1ae8b140c49f08447fcc74f442",
|
||||
@@ -198,126 +138,64 @@ Emitted When:
|
||||
}
|
||||
```
|
||||
|
||||
## new\_market Message
|
||||
### new\_market
|
||||
|
||||
Emitted When:
|
||||
<Note>Requires `custom_feature_enabled: true`.</Note>
|
||||
|
||||
* A new market is created.
|
||||
Emitted when a new market is created.
|
||||
|
||||
(This message is behind the `custom_feature_enabled` flag)
|
||||
|
||||
### Structure
|
||||
|
||||
| Name | Type | Description |
|
||||
| -------------- | --------- | ------------------------------ |
|
||||
| id | string | market ID |
|
||||
| question | string | market question |
|
||||
| market | string | condition ID of market |
|
||||
| slug | string | market slug |
|
||||
| description | string | market description |
|
||||
| assets\_ids | string\[] | list of asset IDs |
|
||||
| outcomes | string\[] | list of outcomes |
|
||||
| event\_message | object | event message object |
|
||||
| timestamp | string | unix timestamp in milliseconds |
|
||||
| event\_type | string | "new\_market" |
|
||||
|
||||
Where a `EventMessage` object is of the form:
|
||||
|
||||
| Name | Type | Description |
|
||||
| ----------- | ------ | ------------------------- |
|
||||
| id | string | event message ID |
|
||||
| ticker | string | event message ticker |
|
||||
| slug | string | event message slug |
|
||||
| title | string | event message title |
|
||||
| description | string | event message description |
|
||||
|
||||
### Example
|
||||
|
||||
```json Response theme={null}
|
||||
```json theme={null}
|
||||
{
|
||||
"id": "1031769",
|
||||
"question": "Will NVIDIA (NVDA) close above $240 end of January?",
|
||||
"market": "0x311d0c4b6671ab54af4970c06fcf58662516f5168997bdda209ec3db5aa6b0c1",
|
||||
"slug": "nvda-above-240-on-january-30-2026",
|
||||
"description": "This market will resolve to \"Yes\" if the official closing price for NVIDIA (NVDA) on the final trading day of January 2026 is higher than the listed price. Otherwise, this market will resolve to \"No\".\n\nIf the final trading day of the month is shortened (for example, due to a market-holiday schedule), the official closing price published for that shortened session will still be used for resolution.\n\nIf no official closing price is published for that session (for example, due to a trading halt into the close, system issue, or other disruption), the market will use the last valid on-exchange trade price of the regular session as the effective closing price.\n\nThe resolution source for this market is Yahoo Finance — specifically, the NVIDIA (NVDA) \"Close\" prices available at https://finance.yahoo.com/quote/NVDA/history, published under \"Historical Prices.\"\n\nIn the event of a stock split, reverse stock split, or similar corporate action affecting the listed company during the listed time frame, this market will resolve based on split-adjusted prices as displayed on Yahoo Finance.",
|
||||
"assets_ids": [
|
||||
"76043073756653678226373981964075571318267289248134717369284518995922789326425",
|
||||
"31690934263385727664202099278545688007799199447969475608906331829650099442770"
|
||||
],
|
||||
"outcomes": [
|
||||
"Yes",
|
||||
"No"
|
||||
],
|
||||
"event_message": {
|
||||
"id": "125819",
|
||||
"ticker": "nvda-above-in-january-2026",
|
||||
"slug": "nvda-above-in-january-2026",
|
||||
"title": "Will NVIDIA (NVDA) close above ___ end of January?",
|
||||
"description": "This market will resolve to \"Yes\" if the official closing price for NVIDIA (NVDA) on the final trading day of January 2026 is higher than the listed price. Otherwise, this market will resolve to \"No\".\n\nIf the final trading day of the month is shortened (for example, due to a market-holiday schedule), the official closing price published for that shortened session will still be used for resolution.\n\nIf no official closing price is published for that session (for example, due to a trading halt into the close, system issue, or other disruption), the market will use the last valid on-exchange trade price of the regular session as the effective closing price.\n\nThe resolution source for this market is Yahoo Finance — specifically, the NVIDIA (NVDA) \"Close\" prices available at https://finance.yahoo.com/quote/NVDA/history, published under \"Historical Prices.\"\n\nIn the event of a stock split, reverse stock split, or similar corporate action affecting the listed company during the listed time frame, this market will resolve based on split-adjusted prices as displayed on Yahoo Finance."
|
||||
},
|
||||
"timestamp": "1766790415550",
|
||||
"event_type": "new_market"
|
||||
"id": "1031769",
|
||||
"question": "Will NVIDIA (NVDA) close above $240 end of January?",
|
||||
"market": "0x311d0c4b6671ab54af4970c06fcf58662516f5168997bdda209ec3db5aa6b0c1",
|
||||
"slug": "nvda-above-240-on-january-30-2026",
|
||||
"description": "This market will resolve to \"Yes\" if the official closing price...",
|
||||
"assets_ids": [
|
||||
"76043073756653678226373981964075571318267289248134717369284518995922789326425",
|
||||
"31690934263385727664202099278545688007799199447969475608906331829650099442770"
|
||||
],
|
||||
"outcomes": ["Yes", "No"],
|
||||
"event_message": {
|
||||
"id": "125819",
|
||||
"ticker": "nvda-above-in-january-2026",
|
||||
"slug": "nvda-above-in-january-2026",
|
||||
"title": "Will NVIDIA (NVDA) close above ___ end of January?",
|
||||
"description": "This market will resolve to \"Yes\" if the official closing price..."
|
||||
},
|
||||
"timestamp": "1766790415550",
|
||||
"event_type": "new_market"
|
||||
}
|
||||
```
|
||||
|
||||
## market\_resolved Message
|
||||
### market\_resolved
|
||||
|
||||
Emitted When:
|
||||
<Note>Requires `custom_feature_enabled: true`.</Note>
|
||||
|
||||
* A market is resolved.
|
||||
Emitted when a market is resolved.
|
||||
|
||||
(This message is behind the `custom_feature_enabled` flag)
|
||||
|
||||
### Structure
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------------ | --------- | ------------------------------ |
|
||||
| id | string | market ID |
|
||||
| question | string | market question |
|
||||
| market | string | condition ID of market |
|
||||
| slug | string | market slug |
|
||||
| description | string | market description |
|
||||
| assets\_ids | string\[] | list of asset IDs |
|
||||
| outcomes | string\[] | list of outcomes |
|
||||
| winning\_asset\_id | string | winning asset ID |
|
||||
| winning\_outcome | string | winning outcome |
|
||||
| event\_message | object | event message object |
|
||||
| timestamp | string | unix timestamp in milliseconds |
|
||||
| event\_type | string | "market\_resolved" |
|
||||
|
||||
Where a `EventMessage` object is of the form:
|
||||
|
||||
| Name | Type | Description |
|
||||
| ----------- | ------ | ------------------------- |
|
||||
| id | string | event message ID |
|
||||
| ticker | string | event message ticker |
|
||||
| slug | string | event message slug |
|
||||
| title | string | event message title |
|
||||
| description | string | event message description |
|
||||
|
||||
### Example
|
||||
|
||||
```json Response theme={null}
|
||||
```json theme={null}
|
||||
{
|
||||
"id": "1031769",
|
||||
"question": "Will NVIDIA (NVDA) close above $240 end of January?",
|
||||
"market": "0x311d0c4b6671ab54af4970c06fcf58662516f5168997bdda209ec3db5aa6b0c1",
|
||||
"slug": "nvda-above-240-on-january-30-2026",
|
||||
"description": "This market will resolve to \"Yes\" if the official closing price for NVIDIA (NVDA) on the final trading day of January 2026 is higher than the listed price. Otherwise, this market will resolve to \"No\".\n\nIf the final trading day of the month is shortened (for example, due to a market-holiday schedule), the official closing price published for that shortened session will still be used for resolution.\n\nIf no official closing price is published for that session (for example, due to a trading halt into the close, system issue, or other disruption), the market will use the last valid on-exchange trade price of the regular session as the effective closing price.\n\nThe resolution source for this market is Yahoo Finance — specifically, the NVIDIA (NVDA) \"Close\" prices available at https://finance.yahoo.com/quote/NVDA/history, published under \"Historical Prices.\"\n\nIn the event of a stock split, reverse stock split, or similar corporate action affecting the listed company during the listed time frame, this market will resolve based on split-adjusted prices as displayed on Yahoo Finance.",
|
||||
"assets_ids": [
|
||||
"76043073756653678226373981964075571318267289248134717369284518995922789326425",
|
||||
"31690934263385727664202099278545688007799199447969475608906331829650099442770"
|
||||
],
|
||||
"winning_asset_id": "76043073756653678226373981964075571318267289248134717369284518995922789326425",
|
||||
"winning_outcome": "Yes",
|
||||
"event_message": {
|
||||
"id": "125819",
|
||||
"ticker": "nvda-above-in-january-2026",
|
||||
"slug": "nvda-above-in-january-2026",
|
||||
"title": "Will NVIDIA (NVDA) close above ___ end of January?",
|
||||
"description": "This market will resolve to \"Yes\" if the official closing price for NVIDIA (NVDA) on the final trading day of January 2026 is higher than the listed price. Otherwise, this market will resolve to \"No\".\n\nIf the final trading day of the month is shortened (for example, due to a market-holiday schedule), the official closing price published for that shortened session will still be used for resolution.\n\nIf no official closing price is published for that session (for example, due to a trading halt into the close, system issue, or other disruption), the market will use the last valid on-exchange trade price of the regular session as the effective closing price.\n\nThe resolution source for this market is Yahoo Finance — specifically, the NVIDIA (NVDA) \"Close\" prices available at https://finance.yahoo.com/quote/NVDA/history, published under \"Historical Prices.\"\n\nIn the event of a stock split, reverse stock split, or similar corporate action affecting the listed company during the listed time frame, this market will resolve based on split-adjusted prices as displayed on Yahoo Finance."
|
||||
},
|
||||
"timestamp": "1766790415550",
|
||||
"event_type": "new_market"
|
||||
"id": "1031769",
|
||||
"question": "Will NVIDIA (NVDA) close above $240 end of January?",
|
||||
"market": "0x311d0c4b6671ab54af4970c06fcf58662516f5168997bdda209ec3db5aa6b0c1",
|
||||
"slug": "nvda-above-240-on-january-30-2026",
|
||||
"description": "This market will resolve to \"Yes\" if the official closing price...",
|
||||
"assets_ids": [
|
||||
"76043073756653678226373981964075571318267289248134717369284518995922789326425",
|
||||
"31690934263385727664202099278545688007799199447969475608906331829650099442770"
|
||||
],
|
||||
"outcomes": ["Yes", "No"],
|
||||
"winning_asset_id": "76043073756653678226373981964075571318267289248134717369284518995922789326425",
|
||||
"winning_outcome": "Yes",
|
||||
"event_message": {
|
||||
"id": "125819",
|
||||
"ticker": "nvda-above-in-january-2026",
|
||||
"slug": "nvda-above-in-january-2026",
|
||||
"title": "Will NVIDIA (NVDA) close above ___ end of January?",
|
||||
"description": "This market will resolve to \"Yes\" if the official closing price..."
|
||||
},
|
||||
"timestamp": "1766790415550",
|
||||
"event_type": "market_resolved"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,54 +4,50 @@
|
||||
|
||||
# User Channel
|
||||
|
||||
Authenticated channel for updates related to user activities (orders, trades), filtered for authenticated user by apikey.
|
||||
> Authenticated order and trade updates
|
||||
|
||||
**SUBSCRIBE**
|
||||
Authenticated channel for updates related to your orders and trades, filtered by API key.
|
||||
|
||||
`<wss-channel> user`
|
||||
## Endpoint
|
||||
|
||||
## Trade Message
|
||||
```
|
||||
wss://ws-subscriptions-clob.polymarket.com/ws/user
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
Include API credentials in your subscription message:
|
||||
|
||||
```json theme={null}
|
||||
{
|
||||
"auth": {
|
||||
"apiKey": "your-api-key",
|
||||
"secret": "your-api-secret",
|
||||
"passphrase": "your-passphrase"
|
||||
},
|
||||
"markets": ["0x1234...condition_id"],
|
||||
"type": "user"
|
||||
}
|
||||
```
|
||||
|
||||
<Warning>
|
||||
Never expose your API credentials in client-side code. Use the user channel
|
||||
only from server environments.
|
||||
</Warning>
|
||||
|
||||
## Message Types
|
||||
|
||||
Each message includes a `type` field identifying the event.
|
||||
|
||||
### trade
|
||||
|
||||
Emitted when:
|
||||
|
||||
* when a market order is matched ("MATCHED")
|
||||
* when a limit order for the user is included in a trade ("MATCHED")
|
||||
* subsequent status changes for trade ("MINED", "CONFIRMED", "RETRYING", "FAILED")
|
||||
* A market order is matched (`MATCHED`)
|
||||
* A limit order for the user is included in a trade (`MATCHED`)
|
||||
* Subsequent status changes for the trade (`MINED`, `CONFIRMED`, `RETRYING`, `FAILED`)
|
||||
|
||||
### Structure
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------------- | ------------- | ------------------------------------------- |
|
||||
| asset\_id | string | asset id (token ID) of order (market order) |
|
||||
| event\_type | string | "trade" |
|
||||
| id | string | trade id |
|
||||
| last\_update | string | time of last update to trade |
|
||||
| maker\_orders | MakerOrder\[] | array of maker order details |
|
||||
| market | string | market identifier (condition ID) |
|
||||
| matchtime | string | time trade was matched |
|
||||
| outcome | string | outcome |
|
||||
| owner | string | api key of event owner |
|
||||
| price | string | price |
|
||||
| side | string | BUY/SELL |
|
||||
| size | string | size |
|
||||
| status | string | trade status |
|
||||
| taker\_order\_id | string | id of taker order |
|
||||
| timestamp | string | time of event |
|
||||
| trade\_owner | string | api key of trade owner |
|
||||
| type | string | "TRADE" |
|
||||
|
||||
Where a `MakerOrder` object is of the form:
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------------- | ------ | -------------------------------------- |
|
||||
| asset\_id | string | asset of the maker order |
|
||||
| matched\_amount | string | amount of maker order matched in trade |
|
||||
| order\_id | string | maker order ID |
|
||||
| outcome | string | outcome |
|
||||
| owner | string | owner of maker order |
|
||||
| price | string | price of maker order |
|
||||
|
||||
```json Response theme={null}
|
||||
```json theme={null}
|
||||
{
|
||||
"asset_id": "52114319501245915516055106046884209969926127482827954674443846427813813222426",
|
||||
"event_type": "trade",
|
||||
@@ -82,34 +78,33 @@ Where a `MakerOrder` object is of the form:
|
||||
}
|
||||
```
|
||||
|
||||
## Order Message
|
||||
#### Trade Statuses
|
||||
|
||||
```
|
||||
MATCHED → MINED → CONFIRMED
|
||||
↓ ↑
|
||||
RETRYING ───┘
|
||||
↓
|
||||
FAILED
|
||||
```
|
||||
|
||||
| Status | Terminal | Description |
|
||||
| ----------- | -------- | ----------------------------------------------------------------------------------------------- |
|
||||
| `MATCHED` | No | Trade has been matched and sent to the executor service by the operator |
|
||||
| `MINED` | No | Trade observed to be mined into the chain, no finality threshold established |
|
||||
| `CONFIRMED` | Yes | Trade has achieved strong probabilistic finality and was successful |
|
||||
| `RETRYING` | No | Trade transaction has failed (revert or reorg) and is being retried/resubmitted by the operator |
|
||||
| `FAILED` | Yes | Trade has failed and is not being retried |
|
||||
|
||||
### order
|
||||
|
||||
Emitted when:
|
||||
|
||||
* When an order is placed (PLACEMENT)
|
||||
* When an order is updated (some of it is matched) (UPDATE)
|
||||
* When an order is canceled (CANCELLATION)
|
||||
* An order is placed (`PLACEMENT`)
|
||||
* An order is updated — some of it is matched (`UPDATE`)
|
||||
* An order is cancelled (`CANCELLATION`)
|
||||
|
||||
### Structure
|
||||
|
||||
| Name | Type | Description |
|
||||
| ----------------- | --------- | ------------------------------------------------------------------- |
|
||||
| asset\_id | string | asset ID (token ID) of order |
|
||||
| associate\_trades | string\[] | array of ids referencing trades that the order has been included in |
|
||||
| event\_type | string | "order" |
|
||||
| id | string | order id |
|
||||
| market | string | condition ID of market |
|
||||
| order\_owner | string | owner of order |
|
||||
| original\_size | string | original order size |
|
||||
| outcome | string | outcome |
|
||||
| owner | string | owner of orders |
|
||||
| price | string | price of order |
|
||||
| side | string | BUY/SELL |
|
||||
| size\_matched | string | size of order that has been matched |
|
||||
| timestamp | string | time of event |
|
||||
| type | string | PLACEMENT/UPDATE/CANCELLATION |
|
||||
|
||||
```json Response theme={null}
|
||||
```json theme={null}
|
||||
{
|
||||
"asset_id": "52114319501245915516055106046884209969926127482827954674443846427813813222426",
|
||||
"associate_trades": null,
|
||||
|
||||
@@ -2,12 +2,180 @@
|
||||
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
|
||||
> Use this file to discover all available pages before exploring further.
|
||||
|
||||
# WSS Authentication
|
||||
# Overview
|
||||
|
||||
<Tip> Only connections to `user` channel require authentication. </Tip>
|
||||
> Real-time market data and trading updates via WebSocket
|
||||
|
||||
| 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 |
|
||||
Polymarket provides WebSocket channels for near real-time streaming of orderbook data, trades, and personal order activity. There are four available channels: `market`, `user`, `sports`, and `RTDS` (Real-Time Data Socket).
|
||||
|
||||
## Channels
|
||||
|
||||
| Channel | Endpoint | Auth |
|
||||
| ----------------------------------- | ------------------------------------------------------ | -------- |
|
||||
| Market | `wss://ws-subscriptions-clob.polymarket.com/ws/market` | No |
|
||||
| User | `wss://ws-subscriptions-clob.polymarket.com/ws/user` | Yes |
|
||||
| Sports | `wss://sports-api.polymarket.com/ws` | No |
|
||||
| [RTDS](/market-data/websocket/rtds) | `wss://ws-live-data.polymarket.com` | Optional |
|
||||
|
||||
### Market Channel
|
||||
|
||||
| Type | Description | Custom Feature |
|
||||
| ------------------ | ----------------------- | -------------- |
|
||||
| `book` | Full orderbook snapshot | No |
|
||||
| `price_change` | Price level updates | No |
|
||||
| `tick_size_change` | Tick size changes | No |
|
||||
| `last_trade_price` | Trade executions | No |
|
||||
| `best_bid_ask` | Best prices update | Yes |
|
||||
| `new_market` | New market created | Yes |
|
||||
| `market_resolved` | Market resolution | Yes |
|
||||
|
||||
Types marked "Custom Feature" require `custom_feature_enabled: true` in your subscription.
|
||||
|
||||
### User Channel
|
||||
|
||||
| Type | Description |
|
||||
| ------- | --------------------------------------------- |
|
||||
| `trade` | Trade lifecycle updates (MATCHED → CONFIRMED) |
|
||||
| `order` | Order placements, updates, and cancellations |
|
||||
|
||||
### Sports
|
||||
|
||||
| Type | Description |
|
||||
| -------------- | ------------------------------------- |
|
||||
| `sport_result` | Live game scores, periods, and status |
|
||||
|
||||
## Subscribing
|
||||
|
||||
Send a subscription message after connecting to specify which data you want to receive.
|
||||
|
||||
### Market Channel
|
||||
|
||||
```json theme={null}
|
||||
{
|
||||
"assets_ids": [
|
||||
"21742633143463906290569050155826241533067272736897614950488156847949938836455",
|
||||
"48331043336612883890938759509493159234755048973500640148014422747788308965732"
|
||||
],
|
||||
"type": "market",
|
||||
"custom_feature_enabled": true
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
| ------------------------ | --------- | ----------------------------------------------------------------- |
|
||||
| `assets_ids` | string\[] | Token IDs to subscribe to |
|
||||
| `type` | string | Channel identifier |
|
||||
| `custom_feature_enabled` | boolean | Enable `best_bid_ask`, `new_market`, and `market_resolved` events |
|
||||
|
||||
### User Channel
|
||||
|
||||
```json theme={null}
|
||||
{
|
||||
"auth": {
|
||||
"apiKey": "your-api-key",
|
||||
"secret": "your-api-secret",
|
||||
"passphrase": "your-passphrase"
|
||||
},
|
||||
"markets": ["0x1234...condition_id"],
|
||||
"type": "user"
|
||||
}
|
||||
```
|
||||
|
||||
<Note>
|
||||
The `auth` fields (`apiKey`, `secret`, `passphrase`) are **only required for
|
||||
the user channel**. For the market channel, these fields are optional and can
|
||||
be omitted.
|
||||
</Note>
|
||||
|
||||
| Field | Type | Description |
|
||||
| --------- | --------- | -------------------------------------------------- |
|
||||
| `auth` | object | API credentials (`apiKey`, `secret`, `passphrase`) |
|
||||
| `markets` | string\[] | Condition IDs to receive events for |
|
||||
| `type` | string | Channel identifier |
|
||||
|
||||
<Note>
|
||||
The user channel subscribes by **condition IDs** (market identifiers), not
|
||||
asset IDs. Each market has one condition ID but two asset IDs (Yes and No
|
||||
tokens).
|
||||
</Note>
|
||||
|
||||
### Sports Channel
|
||||
|
||||
No subscription message required. Connect and start receiving data for all active sports events.
|
||||
|
||||
## Dynamic Subscription
|
||||
|
||||
Modify subscriptions without reconnecting.
|
||||
|
||||
### Subscribe to more assets
|
||||
|
||||
```json theme={null}
|
||||
{
|
||||
"assets_ids": ["new_asset_id_1", "new_asset_id_2"],
|
||||
"operation": "subscribe",
|
||||
"custom_feature_enabled": true
|
||||
}
|
||||
```
|
||||
|
||||
### Unsubscribe from assets
|
||||
|
||||
```json theme={null}
|
||||
{
|
||||
"assets_ids": ["asset_id_to_remove"],
|
||||
"operation": "unsubscribe"
|
||||
}
|
||||
```
|
||||
|
||||
For the user channel, use `markets` instead of `assets_ids`:
|
||||
|
||||
```json theme={null}
|
||||
{
|
||||
"markets": ["0x1234...condition_id"],
|
||||
"operation": "subscribe"
|
||||
}
|
||||
```
|
||||
|
||||
## Heartbeats
|
||||
|
||||
### Market & User Channels
|
||||
|
||||
Send `PING` every 10 seconds. The server responds with `PONG`.
|
||||
|
||||
```
|
||||
PING
|
||||
```
|
||||
|
||||
### Sports Channel
|
||||
|
||||
The server sends `ping` every 5 seconds. Respond with `pong` within 10 seconds.
|
||||
|
||||
```
|
||||
pong
|
||||
```
|
||||
|
||||
<Warning>
|
||||
If you don't respond to the server's ping within 10 seconds, the connection
|
||||
will be closed.
|
||||
</Warning>
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
<Accordion title="Connection closes immediately after opening">
|
||||
Send a valid subscription message immediately after connecting. The server may
|
||||
close connections that don't subscribe within a timeout period.
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Connection drops after ~10 seconds">
|
||||
You're not sending heartbeats. Send `PING` every 10 seconds for market/user
|
||||
channels, or respond to server `ping` with `pong` for the sports channel.
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Not receiving any messages">
|
||||
1. Verify your asset IDs or condition IDs are correct 2. Check that the
|
||||
markets are active (not resolved) 3. Set `custom_feature_enabled: true` if
|
||||
expecting `best_bid_ask`, `new_market`, or `market_resolved` events
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Authentication failed (user channel)">
|
||||
Verify your API credentials are correct and haven't expired.
|
||||
</Accordion>
|
||||
|
||||
@@ -2,35 +2,180 @@
|
||||
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
|
||||
> Use this file to discover all available pages before exploring further.
|
||||
|
||||
# WSS Overview
|
||||
# Overview
|
||||
|
||||
> Overview and general information about the Polymarket Websocket
|
||||
> Real-time market data and trading updates via WebSocket
|
||||
|
||||
## Overview
|
||||
Polymarket provides WebSocket channels for near real-time streaming of orderbook data, trades, and personal order activity. There are four available channels: `market`, `user`, `sports`, and `RTDS` (Real-Time Data Socket).
|
||||
|
||||
The Polymarket CLOB API provides websocket (wss) channels through which clients can get pushed updates. These endpoints allow clients to maintain almost real-time views of their orders, their trades and markets in general. There are two available channels `user` and `market`.
|
||||
## Channels
|
||||
|
||||
## Subscription
|
||||
| Channel | Endpoint | Auth |
|
||||
| ----------------------------------- | ------------------------------------------------------ | -------- |
|
||||
| Market | `wss://ws-subscriptions-clob.polymarket.com/ws/market` | No |
|
||||
| User | `wss://ws-subscriptions-clob.polymarket.com/ws/user` | Yes |
|
||||
| Sports | `wss://sports-api.polymarket.com/ws` | No |
|
||||
| [RTDS](/market-data/websocket/rtds) | `wss://ws-live-data.polymarket.com` | Optional |
|
||||
|
||||
To subscribe send a message including the following authentication and intent information upon opening the connection.
|
||||
### Market Channel
|
||||
|
||||
| Field | Type | Description |
|
||||
| ------------------------ | --------- | --------------------------------------------------------------------------- |
|
||||
| auth | Auth | see next page for auth information |
|
||||
| markets | string\[] | array of markets (condition IDs) to receive events for (for `user` channel) |
|
||||
| assets\_ids | string\[] | array of asset ids (token IDs) to receive events for (for `market` channel) |
|
||||
| type | string | id of channel to subscribe to (USER or MARKET) |
|
||||
| custom\_feature\_enabled | bool | enabling / disabling custom features |
|
||||
| Type | Description | Custom Feature |
|
||||
| ------------------ | ----------------------- | -------------- |
|
||||
| `book` | Full orderbook snapshot | No |
|
||||
| `price_change` | Price level updates | No |
|
||||
| `tick_size_change` | Tick size changes | No |
|
||||
| `last_trade_price` | Trade executions | No |
|
||||
| `best_bid_ask` | Best prices update | Yes |
|
||||
| `new_market` | New market created | Yes |
|
||||
| `market_resolved` | Market resolution | Yes |
|
||||
|
||||
Where the `auth` field is of type `Auth` which has the form described in the WSS Authentication section below.
|
||||
Types marked "Custom Feature" require `custom_feature_enabled: true` in your subscription.
|
||||
|
||||
### User Channel
|
||||
|
||||
| Type | Description |
|
||||
| ------- | --------------------------------------------- |
|
||||
| `trade` | Trade lifecycle updates (MATCHED → CONFIRMED) |
|
||||
| `order` | Order placements, updates, and cancellations |
|
||||
|
||||
### Sports
|
||||
|
||||
| Type | Description |
|
||||
| -------------- | ------------------------------------- |
|
||||
| `sport_result` | Live game scores, periods, and status |
|
||||
|
||||
## Subscribing
|
||||
|
||||
Send a subscription message after connecting to specify which data you want to receive.
|
||||
|
||||
### Market Channel
|
||||
|
||||
```json theme={null}
|
||||
{
|
||||
"assets_ids": [
|
||||
"21742633143463906290569050155826241533067272736897614950488156847949938836455",
|
||||
"48331043336612883890938759509493159234755048973500640148014422747788308965732"
|
||||
],
|
||||
"type": "market",
|
||||
"custom_feature_enabled": true
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
| ------------------------ | --------- | ----------------------------------------------------------------- |
|
||||
| `assets_ids` | string\[] | Token IDs to subscribe to |
|
||||
| `type` | string | Channel identifier |
|
||||
| `custom_feature_enabled` | boolean | Enable `best_bid_ask`, `new_market`, and `market_resolved` events |
|
||||
|
||||
### User Channel
|
||||
|
||||
```json theme={null}
|
||||
{
|
||||
"auth": {
|
||||
"apiKey": "your-api-key",
|
||||
"secret": "your-api-secret",
|
||||
"passphrase": "your-passphrase"
|
||||
},
|
||||
"markets": ["0x1234...condition_id"],
|
||||
"type": "user"
|
||||
}
|
||||
```
|
||||
|
||||
<Note>
|
||||
The `auth` fields (`apiKey`, `secret`, `passphrase`) are **only required for
|
||||
the user channel**. For the market channel, these fields are optional and can
|
||||
be omitted.
|
||||
</Note>
|
||||
|
||||
| Field | Type | Description |
|
||||
| --------- | --------- | -------------------------------------------------- |
|
||||
| `auth` | object | API credentials (`apiKey`, `secret`, `passphrase`) |
|
||||
| `markets` | string\[] | Condition IDs to receive events for |
|
||||
| `type` | string | Channel identifier |
|
||||
|
||||
<Note>
|
||||
The user channel subscribes by **condition IDs** (market identifiers), not
|
||||
asset IDs. Each market has one condition ID but two asset IDs (Yes and No
|
||||
tokens).
|
||||
</Note>
|
||||
|
||||
### Sports Channel
|
||||
|
||||
No subscription message required. Connect and start receiving data for all active sports events.
|
||||
|
||||
## Dynamic Subscription
|
||||
|
||||
Modify subscriptions without reconnecting.
|
||||
|
||||
### Subscribe to more assets
|
||||
|
||||
Once connected, the client can subscribe and unsubscribe to `asset_ids` by sending the following message:
|
||||
```json theme={null}
|
||||
{
|
||||
"assets_ids": ["new_asset_id_1", "new_asset_id_2"],
|
||||
"operation": "subscribe",
|
||||
"custom_feature_enabled": true
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
| ------------------------ | --------- | ------------------------------------------------------------------------------ |
|
||||
| assets\_ids | string\[] | array of asset ids (token IDs) to receive events for (for `market` channel) |
|
||||
| markets | string\[] | array of market ids (condition IDs) to receive events for (for `user` channel) |
|
||||
| operation | string | "subscribe" or "unsubscribe" |
|
||||
| custom\_feature\_enabled | bool | enabling / disabling custom features |
|
||||
### Unsubscribe from assets
|
||||
|
||||
```json theme={null}
|
||||
{
|
||||
"assets_ids": ["asset_id_to_remove"],
|
||||
"operation": "unsubscribe"
|
||||
}
|
||||
```
|
||||
|
||||
For the user channel, use `markets` instead of `assets_ids`:
|
||||
|
||||
```json theme={null}
|
||||
{
|
||||
"markets": ["0x1234...condition_id"],
|
||||
"operation": "subscribe"
|
||||
}
|
||||
```
|
||||
|
||||
## Heartbeats
|
||||
|
||||
### Market & User Channels
|
||||
|
||||
Send `PING` every 10 seconds. The server responds with `PONG`.
|
||||
|
||||
```
|
||||
PING
|
||||
```
|
||||
|
||||
### Sports Channel
|
||||
|
||||
The server sends `ping` every 5 seconds. Respond with `pong` within 10 seconds.
|
||||
|
||||
```
|
||||
pong
|
||||
```
|
||||
|
||||
<Warning>
|
||||
If you don't respond to the server's ping within 10 seconds, the connection
|
||||
will be closed.
|
||||
</Warning>
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
<Accordion title="Connection closes immediately after opening">
|
||||
Send a valid subscription message immediately after connecting. The server may
|
||||
close connections that don't subscribe within a timeout period.
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Connection drops after ~10 seconds">
|
||||
You're not sending heartbeats. Send `PING` every 10 seconds for market/user
|
||||
channels, or respond to server `ping` with `pong` for the sports channel.
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Not receiving any messages">
|
||||
1. Verify your asset IDs or condition IDs are correct 2. Check that the
|
||||
markets are active (not resolved) 3. Set `custom_feature_enabled: true` if
|
||||
expecting `best_bid_ask`, `new_market`, or `market_resolved` events
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Authentication failed (user channel)">
|
||||
Verify your API credentials are correct and haven't expired.
|
||||
</Accordion>
|
||||
|
||||
Reference in New Issue
Block a user