Private WebSocket
The Private WebSocket endpoint provides real-time updates for user-specific data including orders, positions, and account balances.
Endpoint
wss://api.polymarket.us/v1/ws/private
Subscription Types
| Value | Type | Description |
|---|
| 1 | ORDER | Order updates (new, filled, canceled) |
| 3 | POSITION | Position changes |
| 4 | ACCOUNT_BALANCE | Account balance changes |
Order Subscriptions
Subscribe to Orders
{
"subscribe": {
"request_id": "order-sub-1",
"subscription_type": 1,
"market_slugs": ["market-slug-1"]
}
}
Leave market_slugs empty to subscribe to all markets.
Order Snapshot Response
Initial snapshot of open orders:
{
"request_id": "order-sub-1",
"subscription_type": 1,
"order_subscription_snapshot": {
"orders": [
{
"id": "order-123",
"market_slug": "market-slug-1",
"side": 1,
"type": 1,
"price": {"value": "0.55", "currency": "USD"},
"quantity": 100,
"leaves_quantity": 100,
"state": 7
}
],
"eof": true
}
}
Order Update Response
Real-time order execution updates:
{
"request_id": "order-sub-1",
"subscription_type": 1,
"order_subscription_update": {
"execution": {
"id": "exec-456",
"order": {...},
"last_shares": "50",
"last_px": {"value": "0.55", "currency": "USD"},
"type": 1,
"trade_id": "trade-789"
}
}
}
Position Subscriptions
Subscribe to Positions
{
"subscribe": {
"request_id": "pos-sub-1",
"subscription_type": 3,
"market_slugs": ["market-slug-1"]
}
}
Position Update Response
{
"request_id": "pos-sub-1",
"subscription_type": 3,
"position_subscription": {
"before_position": {
"net_position": "100",
"cost": {"value": "55.00", "currency": "USD"}
},
"after_position": {
"net_position": "150",
"cost": {"value": "82.50", "currency": "USD"}
},
"update_time": "2024-01-15T10:30:00Z",
"entry_type": 1,
"trade_id": "trade-789"
}
}
Account Balance Subscriptions
Subscribe to Balances
{
"subscribe": {
"request_id": "balance-sub-1",
"subscription_type": 4
}
}
Balance Snapshot Response
{
"request_id": "balance-sub-1",
"subscription_type": 4,
"account_balances_snapshot": {
"balances": [
{
"current_balance": 1000.00,
"currency": "USD",
"buying_power": 850.00
}
]
}
}
Balance Update Response
{
"request_id": "balance-sub-1",
"subscription_type": 4,
"account_balances_update": {
"balance_change": {
"before_balance": {...},
"after_balance": {...},
"description": "Order execution",
"update_time": "2024-01-15T10:30:00Z",
"entry_type": 1
}
}
}
Execution Types
| Value | Type | Description |
|---|
| 1 | PARTIAL_FILL | Order partially filled |
| 2 | FILL | Order fully filled |
| 3 | CANCELED | Order canceled |
| 5 | REJECTED | Order rejected |
| 6 | EXPIRED | Order expired |
Ledger Entry Types
| Value | Type | Description |
|---|
| 1 | ORDER_EXECUTION | Trade execution |
| 2 | DEPOSIT | Account deposit |
| 3 | WITHDRAWAL | Account withdrawal |
| 4 | RESOLUTION | Market resolution |
| 5 | COMMISSION | Commission charge |
Subscription LimitsYou can subscribe to a maximum of 100 markets per subscription. Use multiple subscriptions if you need more.