GUIDE  ·  LUNARSHADOW AI  ·  UPDATED

Automating Kalshi trades.
From API key to first order.

Kalshi offers a full trading API, so anything you can do by hand you can do in code. Here is what it takes, what to test first, and the risk controls any bot needs.

What the API lets you do

Kalshi's API can read markets and order books, place and cancel orders, and report your positions, fills and balance. A WebSocket feed streams price and order updates as they happen, so a program can react without constantly asking for new data. See Kalshi's API documentation.

Step 1: create an API key

In your Kalshi profile, create an API key. Kalshi supports Ed25519 keys (its recommendation) and RSA keys. It shows the private key once and does not store it, so save it immediately. Your program signs every request with the key ID, a timestamp and a signature; nobody can trade with the key ID alone.

Treat the private key like a password to your trading account. Never paste it into a chat or a shared document, and delete the key in your profile if you think it has leaked.

Step 2: test in the demo environment

Kalshi runs a separate demo environment with mock funds and its own login and keys. Point new code at the demo first and check orders, cancels and error handling there. Demo prices and behavior can differ from the real exchange, so a passing demo run is a check, not a forecast.

Step 3: respect rate limits

Requests draw from a token budget that refills every second. On the Basic tier you get 200 read and 100 write tokens per second, and most requests cost 10 tokens, so roughly 20 reads and 10 orders or cancels per second. The Advanced tier can be requested through the API, and higher tiers come with trading volume. A bot that ignores limits gets throttled at the worst moment, so build in backoff.

Step 4: build in risk controls

Remember that every fill pays Kalshi's trading fee; see how it is calculated.

Your own script or a hosted bot

Writing your own bot gives you full control, and you also own the server, uptime, monitoring and every bug. A hosted bot takes that work off your hands.

With the LunarShadow Kalshi bot, you create the API key in your Kalshi profile, paste the key ID and private key into the app, test the connection, set your size and daily loss cap, and switch it on. The bot runs on LunarShadow's servers, and Revoke switches the stored key off so the bot stops placing orders. Automation does not guarantee a profit.