Connection URLs
| Channel | URL | Auth Required |
|---|
| Market | wss://api.pmx.trade/v2/ws/market | No |
| User | wss://api.pmx.trade/v2/ws/user | No |
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
| Limit | Value |
|---|
| Max subscriptions per connection | 50 |
| Max market connections per IP | 10 |
| Max user connections per IP | 5 |
| Max total connections | 5,000 |
| Message rate limit | 20 messages/second |
| Max message size | 4 KB |
Exceeding the message rate limit closes the connection with code 4029.
Error Events
{
"event": "error",
"message": "Description of the error"
}