Everything K-culture — comebacks to K-beauty, straight to your inboxGet it in your inbox

METAL MEDIA

bobashopcashier/kalshi-cli

19GoMIT

A Go CLI that lets AI agents safely read and trade on Kalshi's prediction markets without getting fooled by silent API changes

kalshi-cli wraps Kalshi's Predictions Trade API v2 so AI agents and scripts can browse and trade prediction markets through stable, bounded JSON output. If Kalshi changes a response's required fields or format, the CLI fails immediately with an UPSTREAM_SCHEMA_MISMATCH error naming the exact broken field, instead of silently passing along bad data. In a 48-case regression test, the CLI detected all 32 injected breaking API changes, while a plain JSON decoder with no validation caught none of them.

What it does

  1. Wraps Kalshi Trade API v2 to expose positions, realized profit/loss, fills, and candlestick (price chart) data as fixed-point numbers in versioned JSON contracts
  2. Fails atomically with an UPSTREAM_SCHEMA_MISMATCH error and names the exact JSON path when Kalshi changes a required field, type, or format
  3. Trading (write) commands are denied by default and require an explicit confirmation flow, a 'governed' write policy
  4. Applies bounded pagination and output limits so responses can't grow unbounded
  5. Its search command does simple case-insensitive substring matching over scanned market pages rather than true full-text search, since Kalshi doesn't offer one, and preserves upstream order instead of ranking by relevance

Why it matters

For anyone building AI agents or automated pipelines that touch live financial data, this guards against a real risk: an API silently changing shape and the agent acting on bad information. It also cuts response size by nearly 80% via field selection, reducing the context cost of feeding data to language models.

Terms in this repo

  • schema validation · checking that received data's structure and format matches what was promised
  • fixed-point number · a numeric format with a fixed decimal position, avoiding rounding errors
  • pagination · splitting large data into pages fetched one at a time
  • candlestick · price chart data showing open, high, low, and close values over a time period
  • deny-by-default · a security principle where requests are rejected unless explicitly allowed

Repository description (English)

Go command-line client for Kalshi Trade API v2 with versioned, schema-validated JSON output.

Open on GitHub

Trending repos

All repos →

Latest from METAL MEDIA