Skip to main content
Connect to wss://api.pmx.trade/v2/ws/user to receive events for your wallet. Your identity is established by including your pubkey in the subscribe message. See the WebSocket Overview for connection details.

order:* — Order Updates

Sent when your orders change state. The event field indicates the new status.
EventTrigger
order:placedOrder accepted and added to the book
order:partially_filledOrder partially matched
order:filledOrder fully filled
order:cancelledOrder cancelled (user-initiated or expired)
{
  "event": "order:cancelled",
  "order": {
    "id": "order-uuid",
    "marketId": "abc-123",
    "side": "buy",
    "outcome": "yes",
    "priceBps": 5500,
    "originalQuantity": "10000000",
    "remainingQuantity": "0",
    "committedAmount": "0",
    "status": "cancelled",
    "orderType": "limit",
    "timeInForce": "gtc",
    "createdAt": "2025-01-15T10:30:00.000Z",
    "updatedAt": "2025-01-15T10:35:00.000Z"
  },
  "timestamp": 1711234567890
}

fill:* — Fill Updates

Sent when your fills progress through settlement.
EventTrigger
fill:matchedFill created from order matching
fill:settlingFill submitted for on-chain settlement
fill:settledFill settled on-chain
fill:failedFill settlement failed
{
  "event": "fill:settled",
  "fill": {
    "id": "fill-uuid",
    "marketId": "abc-123",
    "makerOrderId": "order-1",
    "takerOrderId": "order-2",
    "makerPubkey": "Maker...",
    "takerPubkey": "Taker...",
    "takerSide": "buy",
    "outcome": "yes",
    "priceBps": 5500,
    "quantity": "10000000",
    "usdcAmount": "5500000",
    "fillType": "direct",
    "status": "settled",
    "settleTx": "5kG3...txSig",
    "retryCount": 0,
    "batchId": "batch-uuid",
    "matchedAt": "2025-01-15T10:30:00.000Z",
    "settledAt": "2025-01-15T10:30:05.000Z",
    "createdAt": "2025-01-15T10:30:00.000Z"
  },
  "timestamp": 1711234567890
}

balance:update — Balance Changes

Sent when your balance changes for a specific market (after fills, cancellations, or settlements).
{
  "event": "balance:update",
  "marketId": "abc-123",
  "balances": {
    "collateral": "50000000",
    "yesTokens": "10000000",
    "noTokens": "0",
    "committedCollateral": "5500000",
    "committedYesTokens": "0",
    "committedNoTokens": "0"
  },
  "timestamp": 1711234567890
}

Example: JavaScript Client

const ws = new WebSocket("wss://api.pmx.trade/v2/ws/user");

ws.onopen = () => {
  // Include your pubkey to identify your wallet
  ws.send(JSON.stringify({
    type: "subscribe",
    pubkey: "7xKXabc123...",
    markets: ["your-market-id"],
  }));

  setInterval(() => ws.send("PING"), 14_000);
};

ws.onmessage = (event) => {
  if (event.data === "PONG") return;
  const msg = JSON.parse(event.data);

  if (msg.event.startsWith("order:")) {
    console.log("Order update:", msg.order.status);
  } else if (msg.event.startsWith("fill:")) {
    console.log("Fill update:", msg.fill.status);
  } else if (msg.event === "balance:update") {
    console.log("Balance:", msg.balances);
  }
};

Example: wscat

wscat -c "wss://api.pmx.trade/v2/ws/user"
> {"type":"subscribe","pubkey":"7xKXabc123...","markets":["your-market-id"]}