You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs(configuration): document total_timeout, ws_ping_interval, ws_close_timeout, allow_unknown_host
Closes#300.
* docs(configuration): regroup total_timeout next to retry knobs; clarify allow_unknown_host opt-in
Bot-review follow-up on #304:
- Move `total_timeout` row up next to `retry_max_delay` so retry-related knobs stay grouped.
- Reword `allow_unknown_host` description from ambiguous "Opt out via the field" to explicit "Set `allow_unknown_host=True` or `KALSHI_ALLOW_UNKNOWN_HOST=1` to allow it".
Copy file name to clipboardExpand all lines: docs/configuration.md
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,7 @@ with KalshiClient(key_id="...", private_key_path="...", config=config) as client
36
36
|`max_retries`|`3`| Maximum retry attempts on retryable methods. |
37
37
|`retry_base_delay`|`0.5`| Base for exponential backoff (seconds). |
38
38
|`retry_max_delay`|`30.0`| Cap on any single retry sleep — also caps `Retry-After`. |
39
+
|`total_timeout`|`None`| Wall-clock cap (seconds) across the whole request including all retries. `None` = unbounded; cap with the per-attempt `timeout` only. See [Retries & idempotency](retries.md). |
39
40
|`extra_headers`|`{}`| Extra HTTP headers added to every request. Useful for custom User-Agent. |
40
41
|`ws_base_url`|`wss://api.elections.kalshi.com/trade-api/ws/v2`| WebSocket base URL. |
41
42
|`ws_max_retries`|`10`| Maximum reconnect attempts before the WS gives up. |
@@ -44,6 +45,9 @@ with KalshiClient(key_id="...", private_key_path="...", config=config) as client
44
45
|`ws_json_loads`|`None`| Optional callable for parsing WS frames (e.g. `orjson.loads`). |
45
46
|`ws_json_dumps`|`None`| Optional callable for serializing outbound WS commands. |
46
47
|`limits`|`None`| Connection-pool limits passed to `httpx`. When `None`, the underlying `httpx.Client` uses its own pool defaults. Pass an `httpx.Limits(...)` to tune. See [Performance](websockets.md#performance) for WS sizing guidance. |
48
+
|`ws_ping_interval`|`20.0`| Seconds between WebSocket keepalive pings (forwarded to the `websockets` library). |
49
+
|`ws_close_timeout`|`5.0`| Seconds to wait for a clean WebSocket close handshake before forcing the socket shut. |
50
+
|`allow_unknown_host`|`False`| When `False`, reject `base_url` / `ws_base_url` whose host is not in the Kalshi allowlist (`api.elections.kalshi.com`, `demo-api.kalshi.co`) or a loopback host. Set `allow_unknown_host=True` or `KALSHI_ALLOW_UNKNOWN_HOST=1` to allow it (mock server, proxy, alternate region). (Added in v2.5.0, #250.) |
47
51
48
52
See [Retries & idempotency](retries.md) for what `max_retries`,
49
53
`retry_base_delay`, `retry_max_delay` do at runtime.
@@ -72,8 +76,9 @@ you also need other tuning.
72
76
-`ws_base_url` must be `wss://` for remote hosts; `ws://` is only allowed
73
77
against the same loopback set.
74
78
- Trailing slashes are auto-stripped from both.
75
-
- Unknown hosts log a warning (Kalshi's known hosts are
76
-
`api.elections.kalshi.com` and `demo-api.kalshi.co`).
79
+
- Unknown hosts are rejected by default; opt in via `allow_unknown_host`
80
+
(see the [Fields](#fields) table) or `KALSHI_ALLOW_UNKNOWN_HOST=1`. Kalshi's
81
+
known hosts are `api.elections.kalshi.com` and `demo-api.kalshi.co`.
77
82
78
83
This catches plaintext config slip-ups before any request is sent.
0 commit comments