API Integration: prediction-assistant

arch-api Architecture

architecture

API Integration

Kalshi REST API integration layer. Answers: how does the app communicate with the Kalshi exchange?

Diagram




          
  

Components

Component Purpose Notes
RSA-PSS Signer Signs each API request with user's private key RSA-PSS SHA-256. Signs {timestamp_ms}{HTTP_METHOD}{path}
Kalshi REST API Exchange API for markets, orders, portfolio Base: https://external-api.kalshi.com/trade-api/v2
Kalshi WebSocket Real-time market data streaming wss://api.kalshi.com/trade-api/ws/v2
Demo API Sandbox environment for development https://external-api.demo.kalshi.co/trade-api/v2

Key Decisions

  • RSA-PSS over session tokens — Kalshi requires per-request RSA-PSS SHA-256 signing. No OAuth, no session cookies. Each request carries three headers: KALSHI-ACCESS-KEY, KALSHI-ACCESS-TIMESTAMP, KALSHI-ACCESS-SIGNATURE.
  • Basic tier rate limits constrain scanning — 20 reads/sec and 10 writes/sec at Basic tier. Watchdog strategy (scanning all live markets) must stay within these bounds. Poll only same-day markets, batch where possible.
  • Demo-first development — All development and testing against demo.kalshi.co. Production keys used only in deployed app with real user accounts.
  • No fund handling — The app never touches deposits or withdrawals. All money flows through Kalshi directly. We only read balances and execute trades via API.
  • WebSocket for live monitoring — REST polling is sufficient for market scanning at Basic tier, but WebSocket provides real-time updates for active position monitoring without burning read quota.

Rate Limits

Tier Read/sec Write/sec
Basic 20 10
Advanced 30 30
Premier 100 100
Prime 400 400

Key Endpoint Groups

Group Key Endpoints Usage
Markets GET /markets, GET /markets/{ticker}/orderbook Market scanning, orderbook analysis
Orders POST /portfolio/orders, DELETE /portfolio/orders/{id} Trade execution and cancellation
Portfolio GET /portfolio/positions, GET /portfolio/balance Position tracking, balance checks
Events GET /events, GET /events/{ticker} Event metadata, fee schedules