Connect & authenticate
Connect & authenticate
Endpoints
Open a WebSocket to /ws on the same host as the REST API:
Authenticate
Authentication is the first message you send, not a query parameter or header. The socket accepts either a first-party JWT or an API key:
An API key used on the WebSocket must carry the websocket scope. Both key classes
authenticate the feed: a drzl_test_ key and a drzl_live_ key are accepted the same
way — the key class governs paper-vs-live routing for REST trading writes, not the
read/subscribe-oriented WebSocket feed. Use a drzl_test_ key against staging for the
Playground.
You have a few seconds to send the auth frame after the socket opens. An anonymous connection (no auth frame, or an auth frame with no credentials) is allowed — it can subscribe to the public market-data channels but not to your private stream.
On success the server sends a connected frame; if you authenticated, your private
user:{your_id} channel is auto-subscribed:
Subscribe
Send a subscribe frame with up to 50 channels. Public channels need no auth; private
channels are authorized on subscribe and rejected (never silently dropped) if you may not
read them.
The server acknowledges with the accepted channels, any rejects with a reason, and a replay summary per channel:
A rejected private channel comes back in errors with a structured reason
(AUTH_REQUIRED, FORBIDDEN, UNKNOWN_CHANNEL, or TIER_NOT_ENTITLED).
A minimal client (Python)
The official Python SDK ships a tested async WebSocket client that defaults to staging
and handles the auth frame, ping/pong, and reconnects for you (from
sdks/python/drazill/_websocket.py,
exercised by sdks/python/tests/test_websocket.py):
The client replies to the server’s ping with a pong for you. If you write your own
client, you must do the same — a missed pong past two heartbeat intervals closes the
socket. See Limits & retention.
Never paste a drzl_live_ key into a browser or client-side app. Use a drzl_test_
key against staging for anything interactive, including the Playground.

