Skip to main content

Private WebSocket

The Private WebSocket endpoint provides real-time updates for user-specific data including orders, positions, and account balances.
Authentication RequiredThis WebSocket endpoint requires Ed25519 signature authentication in the connection handshake. See the Authentication guide for details.

Endpoint

wss://api.polymarket.us/v1/ws/private

Subscription Types

ValueDescription
SUBSCRIPTION_TYPE_ORDEROrder updates (new, filled, canceled)
SUBSCRIPTION_TYPE_ORDER_SNAPSHOTInitial snapshot of open orders
SUBSCRIPTION_TYPE_POSITIONPosition changes
SUBSCRIPTION_TYPE_ACCOUNT_BALANCEAccount balance changes

Order Subscriptions

Subscribe to Orders

{
  "subscribe": {
    "requestId": "order-sub-1",
    "subscriptionType": "SUBSCRIPTION_TYPE_ORDER",
    "marketSlugs": ["market-slug-1"]
  }
}
Leave marketSlugs empty to subscribe to all markets.

Order Snapshot Response

Initial snapshot of open orders:
{
  "requestId": "order-sub-1",
  "subscriptionType": "SUBSCRIPTION_TYPE_ORDER",
  "orderSubscriptionSnapshot": {
    "orders": [
      {
        "id": "order-123",
        "marketSlug": "market-slug-1",
        "side": "ORDER_SIDE_BUY",
        "type": "ORDER_TYPE_LIMIT",
        "price": {"value": "0.55", "currency": "USD"},
        "quantity": 100,
        "leavesQuantity": 100,
        "state": "ORDER_STATE_PENDING_NEW",
        "intent": "ORDER_INTENT_BUY_LONG",
        "tif": "TIME_IN_FORCE_GOOD_TILL_CANCEL"
      }
    ],
    "eof": true
  }
}

Order Update Response

Real-time order execution updates:
{
  "requestId": "order-sub-1",
  "subscriptionType": "SUBSCRIPTION_TYPE_ORDER",
  "orderSubscriptionUpdate": {
    "execution": {
      "id": "exec-456",
      "order": {...},
      "lastShares": "50",
      "lastPx": {"value": "0.55", "currency": "USD"},
      "type": "EXECUTION_TYPE_PARTIAL_FILL",
      "tradeId": "trade-789"
    }
  }
}

Position Subscriptions

Subscribe to Positions

{
  "subscribe": {
    "requestId": "pos-sub-1",
    "subscriptionType": "SUBSCRIPTION_TYPE_POSITION",
    "marketSlugs": ["market-slug-1"]
  }
}

Position Update Response

{
  "requestId": "pos-sub-1",
  "subscriptionType": "SUBSCRIPTION_TYPE_POSITION",
  "positionSubscription": {
    "beforePosition": {
      "netPosition": "100",
      "cost": {"value": "55.00", "currency": "USD"}
    },
    "afterPosition": {
      "netPosition": "150",
      "cost": {"value": "82.50", "currency": "USD"}
    },
    "updateTime": "2024-01-15T10:30:00Z",
    "entryType": "LEDGER_ENTRY_TYPE_ORDER_EXECUTION",
    "tradeId": "trade-789"
  }
}

Account Balance Subscriptions

Subscribe to Balances

{
  "subscribe": {
    "requestId": "balance-sub-1",
    "subscriptionType": "SUBSCRIPTION_TYPE_ACCOUNT_BALANCE"
  }
}

Balance Snapshot Response

{
  "requestId": "balance-sub-1",
  "subscriptionType": "SUBSCRIPTION_TYPE_ACCOUNT_BALANCE",
  "accountBalancesSnapshot": {
    "balances": [
      {
        "currentBalance": 1000.00,
        "currency": "USD",
        "buyingPower": 850.00
      }
    ]
  }
}

Balance Update Response

{
  "requestId": "balance-sub-1",
  "subscriptionType": "SUBSCRIPTION_TYPE_ACCOUNT_BALANCE",
  "accountBalancesUpdate": {
    "balanceChange": {
      "beforeBalance": {...},
      "afterBalance": {...},
      "description": "Order execution",
      "updateTime": "2024-01-15T10:30:00Z",
      "entryType": "LEDGER_ENTRY_TYPE_ORDER_EXECUTION"
    }
  }
}

Execution Types

ValueDescription
EXECUTION_TYPE_PARTIAL_FILLOrder partially filled
EXECUTION_TYPE_FILLOrder fully filled
EXECUTION_TYPE_CANCELEDOrder canceled
EXECUTION_TYPE_REPLACEOrder replaced/modified
EXECUTION_TYPE_REJECTEDOrder rejected
EXECUTION_TYPE_EXPIREDOrder expired
EXECUTION_TYPE_DONE_FOR_DAYOrder done for the trading day

Ledger Entry Types

ValueDescription
LEDGER_ENTRY_TYPE_ORDER_EXECUTIONTrade execution
LEDGER_ENTRY_TYPE_DEPOSITAccount deposit
LEDGER_ENTRY_TYPE_WITHDRAWALAccount withdrawal
LEDGER_ENTRY_TYPE_RESOLUTIONMarket resolution
LEDGER_ENTRY_TYPE_COMMISSIONCommission charge
LEDGER_ENTRY_TYPE_CORRECTIONBalance correction
LEDGER_ENTRY_TYPE_NETTINGNetting adjustment
LEDGER_ENTRY_TYPE_MANUAL_ADJUSTMENTManual balance adjustment
LEDGER_ENTRY_TYPE_CONTRACT_EXPIRATIONContract expiration

Order States

ValueDescription
ORDER_STATE_PENDING_NEWOrder received, not yet processed
ORDER_STATE_PENDING_REPLACEModify request received, not yet processed
ORDER_STATE_PENDING_CANCELCancel request received, not yet processed
ORDER_STATE_PENDING_RISKOrder pending risk approval
ORDER_STATE_PARTIALLY_FILLEDOrder partially executed
ORDER_STATE_FILLEDOrder fully executed
ORDER_STATE_CANCELEDOrder canceled
ORDER_STATE_REPLACEDOrder replaced
ORDER_STATE_REJECTEDOrder rejected
ORDER_STATE_EXPIREDOrder expired

Order Intent

ValueDescription
ORDER_INTENT_BUY_LONGBuy YES shares
ORDER_INTENT_SELL_LONGSell YES shares
ORDER_INTENT_BUY_SHORTBuy NO shares
ORDER_INTENT_SELL_SHORTSell NO shares
Subscription LimitsYou can subscribe to a maximum of 100 markets per subscription. Use multiple subscriptions if you need more.