Skip to content

Commit f1e1501

Browse files
authored
docs(configuration): document total_timeout, ws_ping_interval, ws_close_timeout, allow_unknown_host (#304)
* 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".
1 parent c6f9a63 commit f1e1501

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

docs/configuration.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ with KalshiClient(key_id="...", private_key_path="...", config=config) as client
3636
| `max_retries` | `3` | Maximum retry attempts on retryable methods. |
3737
| `retry_base_delay` | `0.5` | Base for exponential backoff (seconds). |
3838
| `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). |
3940
| `extra_headers` | `{}` | Extra HTTP headers added to every request. Useful for custom User-Agent. |
4041
| `ws_base_url` | `wss://api.elections.kalshi.com/trade-api/ws/v2` | WebSocket base URL. |
4142
| `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
4445
| `ws_json_loads` | `None` | Optional callable for parsing WS frames (e.g. `orjson.loads`). |
4546
| `ws_json_dumps` | `None` | Optional callable for serializing outbound WS commands. |
4647
| `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.) |
4751

4852
See [Retries & idempotency](retries.md) for what `max_retries`,
4953
`retry_base_delay`, `retry_max_delay` do at runtime.
@@ -72,8 +76,9 @@ you also need other tuning.
7276
- `ws_base_url` must be `wss://` for remote hosts; `ws://` is only allowed
7377
against the same loopback set.
7478
- 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`.
7782

7883
This catches plaintext config slip-ups before any request is sent.
7984

0 commit comments

Comments
 (0)