A thin, JSON-first command-line wrapper around Kalshi's official
kalshi_python_sync SDK. Built so an LLM agent (Claude Code or any other) can
pull Kalshi market data reliably by running one shell command and reading JSON.
- Every command prints one JSON document to stdout.
- Errors print
{"error": ...}to stderr and exit non-zero. - Market data needs no credentials. Only account/portfolio + streaming do.
Already done in this folder: a .venv with kalshi_python_sync installed.
To recreate elsewhere:
python3 -m venv .venv # needs Python 3.13+
./.venv/bin/pip install kalshi-python-syncRun via the ./kalshi launcher (it loads .env and uses the venv). Optionally
symlink it onto your PATH: ln -s "$PWD/kalshi" ~/.local/bin/kalshi.
./kalshi status # exchange health
./kalshi markets --status open --limit 100 # list markets
./kalshi markets --search "president" # client-side title/ticker filter
./kalshi market KXELONMARS-99 # one market (bids/asks/volume)
./kalshi orderbook KXELONMARS-99 --depth 5 # order book
./kalshi trades KXELONMARS-99 --limit 20 # recent trades (the tape)
./kalshi events --status open --search fed # list/search events
./kalshi event KXNEXTATLFED-30JAN01 --markets
./kalshi series KXPRESPrices come back as decimal-dollar strings in *_dollars fields
(e.g. yes_bid_dollars: "0.12"); sizes/volumes in *_fp fields.
Add --pretty for indented JSON (works before or after the subcommand).
Add --demo to hit the sandbox.
Create an API key in the Kalshi web app (Settings → API Keys), download the
RSA .pem, then cp .env.example .env and fill in:
KALSHI_API_KEY_ID=...
KALSHI_PRIVATE_KEY_PATH=/absolute/path/to/private_key.pem
./kalshi balance
./kalshi positions --limit 50The SDK signs each request (RSA-PSS) for you. Auth is wired up only when both env vars are present — public commands keep working without them.
REST commands are "real-time enough" for most agent workflows (call them when you need fresh data). For a continuous push feed:
./.venv/bin/pip install websockets # one-time
./kalshi stream KXELONMARS-99 --channel ticker_v2,tradeNeeds credentials; emits newline-delimited JSON, one message per line.
- Official SDK underneath, so output tracks the live API (the SDK is regenerated weekly from Kalshi's OpenAPI spec).
- No field guessing — responses are dumped straight from SDK models.
- Simple — one command in, JSON out.