Skip to main content

Connection URLs

ChannelURLAuth Required
Marketwss://api.pmx.trade/v2/ws/marketNo
Userwss://api.pmx.trade/v2/ws/userNo

Heartbeat

Send PING (text) every 15 seconds. The server responds with PONG. Connections that miss heartbeats for 30 seconds are terminated.
setInterval(() => ws.send("PING"), 14_000);

User Channel — Identification via Subscribe

The user channel is open to connect without authentication. Your wallet identity is established by including your pubkey in the subscribe message:
const ws = new WebSocket("wss://api.pmx.trade/v2/ws/user");

ws.onopen = () => {
  ws.send(JSON.stringify({
    type: "subscribe",
    pubkey: "7xKXabc123...",
    markets: ["market-id-1", "market-id-2"],
  }));
};
Response:
{ "event": "subscribed", "markets": ["market-id-1", "market-id-2"] }

Subscribing to Markets

Both channels use the same subscribe/unsubscribe format:
{
  "type": "subscribe",
  "pubkey": "7xKXabc123...",
  "markets": ["market-id-1", "market-id-2"]
}
To unsubscribe:
{
  "type": "unsubscribe",
  "markets": ["market-id-1"]
}
The pubkey field is required for the user channel subscribe message but not for the market channel.

Limits

LimitValue
Max subscriptions per connection50
Max market connections per IP10
Max user connections per IP5
Max total connections5,000
Message rate limit20 messages/second
Max message size4 KB
Exceeding the message rate limit closes the connection with code 4029.

Error Events

{
  "event": "error",
  "message": "Description of the error"
}