# Kalshi API

Kalshi exchange mechanics, RSA-PSS auth, order schema, YES/NO orderbook convention...

- Repository: https://github.com/agiprolabs/claude-trading-skills (507 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-09-03
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add agiprolabs/claude-trading-skills --skill kalshi-api -g -a claude-code -y`
Codex: `npx skills add agiprolabs/claude-trading-skills --skill kalshi-api -g -a codex -y`
Cursor: `npx skills add agiprolabs/claude-trading-skills --skill kalshi-api -g -a cursor -y`
Gemini CLI: `npx skills add agiprolabs/claude-trading-skills --skill kalshi-api -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add agiprolabs/claude-trading-skills`

## Description

Kalshi exchange mechanics, RSA-PSS auth, order schema, YES/NO orderbook convention, WebSocket, and endpoint surface. Market-type-agnostic shared layer for all Kalshi skills.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Kalshi API

CFTC-regulated US event exchange. USD-denominated binary contracts settle at $1.00 (YES wins) or $0.00 (NO wins). REST + WebSocket, RSA-PSS authentication on every request.

For contract semantics and settlement rules, see the `kalshi-weather-markets` and `kalshi-crypto-index-markets` skills. For strategy, sizing, and backtesting, see `prediction-market-strategy`.

---

> **VERIFY BEFORE CODING.**
> The Kalshi API has broken backward compatibility before: the host changed (old `trading-api.kalshi.com` → dead), and the order schema changed (integer cents → dollar strings). Always smoke-test signing and order bodies against a live response before shipping.
>
> Canonical sources:
> - API reference: <https://docs.kalshi.com> (legacy mirror: <https://trading-api.readme.io>)
> - Official Python starter: <https://github.com/Kalshi/kalshi-starter-code-python>

---

## Overview

- **Base URL:** `https://api.elections.kalshi.com/trade-api/v2`
- **Auth:** RSA-PSS on every request, there are no public/unauthenticated endpoints
- **No demo parity:** the demo environment (`demo-api.kalshi.co`) has a near-empty book; use production even for read-only pulls
- **Contracts:** $0.01, $0.99 per contract; pay price if YES wins, lose price if NO wins; max payout = $1.00

---

## Quick Start

### 1. Credentials

```
KALSHI_KEY_ID=<your-key-uuid>
KALSHI_PRIVATE_KEY_PATH=~/.kalshi/private.pem
```

Generate the key in the Kalshi dashboard. Store secrets in environment variables or a secrets manager, never in code.

### 2. Install

```bash
pip install httpx cryptography
```

### 3. Host + auth (the part everyone gets wrong)

The host and signature format are where implementations break. Three common failures:
1. Using the old `trading-api.kalshi.com` host → 401
2. Including the query string in the signed path → 401
3. Signing with seconds instead of milliseconds → 401

The rest: https://github.com/agiprolabs/claude-trading-skills/blob/HEAD/skills/kalshi-api/SKILL.md
