Skip to content

Commit a4f7881

Browse files
committed
docs: replace curl with raw websocket python example
1 parent fc48308 commit a4f7881

2 files changed

Lines changed: 9 additions & 78 deletions

File tree

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [2.46.13] - 2026-05-26
6+
7+
### Fixed
8+
9+
- **Docs**: Replace the raw WebSocket curl examples for `watchAllOrderBooks()` with a direct Python WebSocket example for non-SDK users.
10+
511
## [2.46.12] - 2026-05-26
612

713
### Fixed

docs/api-reference/watch-all-order-books.mdx

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ while (true) {
6565
}
6666
```
6767

68-
```bash curl
69-
export PMXT_API_KEY="YOUR_PMXT_API_KEY"
70-
71-
printf '%s\n' '{"id":"all-books","action":"subscribe","method":"watchAllOrderBooks"}' \
72-
| curl --no-progress-meter --no-buffer --http1.1 -T . \
73-
"wss://api.pmxt.dev/ws?apiKey=${PMXT_API_KEY}"
74-
```
75-
7668
</CodeGroup>
7769

7870
### Raw WebSocket without an SDK
@@ -84,54 +76,7 @@ Use this when you are not using the Python or TypeScript SDKs, or when you are i
8476
| Hosted PMXT | `wss://api.pmxt.dev/ws?apiKey=YOUR_PMXT_API_KEY` |
8577
| Local hosted-compatible relay | `ws://localhost:5005/ws?apiKey=YOUR_PMXT_API_KEY` |
8678

87-
curl supports WebSocket when `curl --version` lists `ws` and `wss` under protocols. These piped examples require curl `8.16.0` or newer so curl can send the subscription frame from stdin. curl `8.11.x` can list `ws` / `wss` but still fail here with `curl: (22) Refused WebSockets upgrade: 400`.
88-
89-
<Warning>
90-
Do not put quote characters around the API key inside the URL. `?apiKey='pmxt_...'` sends the quotes as part of the key and the WebSocket upgrade will be rejected.
91-
</Warning>
92-
93-
If you still see `curl: (22) Refused WebSockets upgrade: 400`, use curl `8.16.0` or newer, or use the raw Python WebSocket example below.
94-
95-
```bash
96-
export PMXT_API_KEY="YOUR_PMXT_API_KEY"
97-
export PMXT_WS_URL="wss://api.pmxt.dev/ws"
98-
99-
curl --version
100-
# Confirm the version is 8.16.0+ and the Protocols line includes ws and wss.
101-
102-
printf '%s\n' '{"id":"all-books","action":"subscribe","method":"watchAllOrderBooks"}' \
103-
| curl --no-progress-meter --no-buffer --http1.1 -T . \
104-
"${PMXT_WS_URL}?apiKey=${PMXT_API_KEY}"
105-
```
106-
107-
If you inline the key, do it without quotes around the query value:
108-
109-
```bash
110-
printf '%s\n' '{"id":"all-books","action":"subscribe","method":"watchAllOrderBooks"}' \
111-
| curl --no-progress-meter --no-buffer --http1.1 -T . \
112-
"wss://api.pmxt.dev/ws?apiKey=YOUR_PMXT_API_KEY"
113-
```
114-
115-
For a single venue, put the venue list in `args`:
116-
117-
```bash
118-
export PMXT_API_KEY="YOUR_PMXT_API_KEY"
119-
export PMXT_WS_URL="wss://api.pmxt.dev/ws"
120-
121-
printf '%s\n' '{"id":"kalshi-books","action":"subscribe","method":"watchAllOrderBooks","args":[["kalshi"]]}' \
122-
| curl --no-progress-meter --no-buffer --http1.1 -T . \
123-
"${PMXT_WS_URL}?apiKey=${PMXT_API_KEY}"
124-
```
125-
126-
When testing a PMXT-compatible hosted relay locally, use the same message shape and switch only the URL:
127-
128-
```bash
129-
export PMXT_WS_URL="ws://localhost:5005/ws"
130-
```
131-
132-
Do not use `--data` or `--data-binary` for this. Those options send an HTTP request body instead of a WebSocket frame.
133-
134-
If your curl is older, use a WebSocket client library directly. This Python example does not use the PMXT SDK; it connects to the same raw WebSocket URL that a Rust or Go client would use.
79+
This Python example does not use the PMXT SDK; it connects to the same raw WebSocket URL that a Rust or Go client would use.
13580

13681
```bash
13782
pip install websockets
@@ -156,25 +101,13 @@ async def main():
156101
url = f"{PMXT_WS_URL}?apiKey={PMXT_API_KEY}"
157102
async with websockets.connect(url) as ws:
158103
await ws.send(json.dumps({
159-
"id": "kalshi-books",
104+
"id": "all-books",
160105
"action": "subscribe",
161106
"method": "watchAllOrderBooks",
162-
"args": [["kalshi"]],
163107
}))
164108

165109
async for raw in ws:
166-
msg = json.loads(raw)
167-
if msg.get("event") != "data":
168-
print(msg)
169-
continue
170-
171-
book = msg["data"]
172-
print({
173-
"source": msg["source"],
174-
"symbol": msg["symbol"],
175-
"bestBid": book.get("bids", [])[:1],
176-
"bestAsk": book.get("asks", [])[:1],
177-
})
110+
print(raw)
178111

179112

180113
asyncio.run(main())
@@ -270,14 +203,6 @@ while (true) {
270203
}
271204
```
272205

273-
```bash curl
274-
export PMXT_API_KEY="YOUR_PMXT_API_KEY"
275-
276-
printf '%s\n' '{"id":"poly-limitless","action":"subscribe","method":"watchAllOrderBooks","args":[["polymarket","limitless"]]}' \
277-
| curl --no-progress-meter --no-buffer --http1.1 -T . \
278-
"wss://api.pmxt.dev/ws?apiKey=${PMXT_API_KEY}"
279-
```
280-
281206
</CodeGroup>
282207

283208
### Force all venues from a venue client

0 commit comments

Comments
 (0)