Skip to content

Subscribing

See Connection Details for keep-alive, limits, and errors.

Published market data (trades, BBOs, etc.) in PAX unified event format. See Message Details.

wss://api.pax.markets/v1/public/spot/market-data
Request
{"action": "subscribe", "market_ids": [1]}
Response
{"type": "subscribed", "market_ids": [1]}

The reply omits invalid, inactive, and duplicate market IDs. Each subscribed market then receives a snapshot followed by md_event_detail messages; see Book Building.

Request
{"action": "unsubscribe", "market_ids": [1]}
Response
{"type": "unsubscribed", "market_ids": [1]}

The reply lists only markets you were subscribed to.

Order and λ status updates for your account, including fills and confirmations. See Message Details.

wss://api.pax.markets/v1/private/spot/user-data

Sign the handshake like a REST request, with GET, the path (no query string), and an empty body; see Authentication. recvWindow isn’t supported. A failed handshake returns HTTP 401.

Request
{"action": "subscribe", "osu": [1, 2], "lsu": true}
Response
{"type": "subscribed", "osu": [1, 2], "lsu": true}

osu lists the markets to receive order status updates for. lsu: true adds λ status updates for all markets. Both are optional; lsu defaults to false. Subscribers first receive a snapshot, then the updates.

Request
{"action": "unsubscribe", "osu": [1], "lsu": false}
Response
{"type": "unsubscribed", "osu": [1], "lsu": false}

osu lists the markets to stop order status updates for, and lsu: true stops λ status updates. The reply lists only what was removed.

Example: subscribing to and streaming user data

Section titled “Example: subscribing to and streaming user data”
import json
import time
import base64
import threading
from cryptography.hazmat.primitives.serialization import load_pem_private_key
from websockets.sync import client
def ping(ws):
while True:
time.sleep(20)
ws.send(json.dumps({"action": "ping"}))
def connect():
private_key = load_pem_private_key(open("my-private-key.pem", "rb").read(), password=None)
key_id = "pax_live_000000000000"
path = "/v1/private/spot/user-data"
timestamp = str(int(time.time() * 1000))
signature = base64.b64encode(private_key.sign(f"{timestamp}GET{path}".encode())).decode()
headers = {"api-access-key": key_id, "api-timestamp": timestamp, "api-signature": signature}
with client.connect(f"wss://api.pax.markets{path}", additional_headers=headers) as ws:
ws.send(json.dumps({"action": "subscribe", "osu": [1], "lsu": True}))
threading.Thread(target=ping, args=(ws,), daemon=True).start()
for msg in ws:
print(msg)

Regulated services provided by 1Money USA, Inc., a licensed money transmitter, NMLS ID 2628653 · Licenses