Subscribing
See Connection Details for keep-alive, limits, and errors.
Market Data
Section titled “Market Data”Published market data (trades, BBOs, etc.) in PAX unified event format. See Message Details.
wss://api.pax.markets/v1/public/spot/market-dataSubscribe
Section titled “Subscribe”{"action": "subscribe", "market_ids": [1]}{"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.
Unsubscribe
Section titled “Unsubscribe”{"action": "unsubscribe", "market_ids": [1]}{"type": "unsubscribed", "market_ids": [1]}The reply lists only markets you were subscribed to.
User Data
Section titled “User Data”Order and λ status updates for your account, including fills and confirmations. See Message Details.
wss://api.pax.markets/v1/private/spot/user-dataAuthenticate
Section titled “Authenticate”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.
Subscribe
Section titled “Subscribe”{"action": "subscribe", "osu": [1, 2], "lsu": true}{"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.
Unsubscribe
Section titled “Unsubscribe”{"action": "unsubscribe", "osu": [1], "lsu": false}{"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 jsonimport timeimport base64import threading
from cryptography.hazmat.primitives.serialization import load_pem_private_keyfrom 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