How to Vibe-Code a Kalshi Trading Bot with AI in an Afternoon

Pick the AI assistant you already use, grab a free API key, connect it to real Kalshi market data, and let it build you a simple prediction-market bot. No deep coding background needed.

What "vibe-coding" actually means

Vibe-coding is just building software by chatting with an AI assistant in plain English. You describe what you want, the AI writes the code, you run it, and you nudge it until it works. You stay in the driver's seat on ideas; the AI handles the typing.

In this guide you'll vibe-code a small Kalshi trading bot (really, a market scanner and analysis script) that does two useful things:

  • Pulls a list of live Kalshi markets and lets you filter by category.
  • Looks at how often markets in a category actually resolve YES, then flags interesting ones.

Here's the fun hook: outcome rates are wildly uneven across categories. In the Kalshi history, Crypto markets resolve YES only about 26% of the time. That kind of pattern is exactly what a bot can explore. We'll feed your AI real data so it works from the actual numbers instead of guessing.

Time needed: about an afternoon, even if you've never shipped code before. Cost to start: zero, you test everything on free sample data first.

Tip A few words you'll see: an API is a doorway that lets your code ask a server for data. An API key is your personal password for that doorway. MCP (Model Context Protocol) is a standard that lets your AI assistant call that doorway by itself, so it can fetch real Kalshi data while it helps you.

Step 1: Get your free API key

Head to the free key form on the homepage, drop in your email, and you'll get a key instantly. No credit card. The free tier is rate-limited sample access, which is perfect for learning and testing.

You'll send the key as a header called X-API-Key on every request. Keep it somewhere safe, like a note or a .env file, and don't paste it into public chats or commit it to a public repo.

Tip You can even skip the key at first. The MCP endpoint works with no key for sample data; adding your key just raises the limits. So you can literally start poking around before you sign up for anything.

Step 2: Connect KalshiAPI to your AI

This is where the magic happens. We'll wire the KalshiAPI MCP server into your assistant so it can query real markets while it builds with you. Pick your tool below.

The MCP endpoint is https://kalshiapi.com/mcp. Once connected, your AI gets these tools: dataset_stats, category_yes_rates, list_markets, get_market, get_candles, and get_trades.

Claude Desktop and Claude Code support MCP servers directly. Add this to your MCP config (in Claude Desktop: Settings, then Developer, then Edit Config), then restart Claude:

{
  "mcpServers": {
    "kalshiapi": {
      "url": "https://kalshiapi.com/mcp",
      "headers": { "X-API-Key": "YOUR_KEY" }
    }
  }
}

After restarting, ask Claude something like "list the kalshiapi tools you have" to confirm it connected. Now Claude can pull real Kalshi data on its own.

Cursor supports MCP too. Create or edit .cursor/mcp.json in your project (or the global config under Cursor Settings, then MCP), add the server, and reload:

{
  "mcpServers": {
    "kalshiapi": {
      "url": "https://kalshiapi.com/mcp",
      "headers": { "X-API-Key": "YOUR_KEY" }
    }
  }
}

Open the MCP settings panel and check that "kalshiapi" shows a green dot. Then chat with Cursor's agent and it can fetch live markets while it writes your code.

Plain ChatGPT does not load arbitrary MCP servers from a config file the way Claude and Cursor do, so the simplest path is to use the REST API directly. Have ChatGPT write Python for you (see Step 4), or, if you have ChatGPT's developer/custom tool features, point a custom action at our REST base:

Base URL:  https://kalshiapi.com
Auth header:  X-API-Key: YOUR_KEY
Endpoints:  GET /v1/markets
            GET /v1/markets/{ticker}/candles
            GET /v1/markets/{ticker}/trades
            GET /v1/stats

For most beginners the easy move is: ask ChatGPT to "write a Python script that calls the KalshiAPI REST endpoints above with my X-API-Key header." It will generate code you run locally.

GitHub Copilot's MCP support is rolling out and varies by editor, so the most reliable path is to use the REST API right in your code. Tell Copilot Chat what you want and have it write the requests against our endpoints:

Base URL:  https://kalshiapi.com
Auth header:  X-API-Key: YOUR_KEY
Endpoints:  GET /v1/markets
            GET /v1/markets/{ticker}/candles
            GET /v1/markets/{ticker}/trades
            GET /v1/stats

Open a new Python file, write a comment describing the call you want, and let Copilot autocomplete it. The Step 4 starter below is a great seed to paste in first.

Tip Not every tool supports MCP yet, and that's totally fine. If your assistant can't load an MCP server, just use the plain REST API in code (Step 4). Same data, slightly more typing.

Step 3: Prompt your AI

Now talk to your assistant like a teammate. If you connected MCP, it can answer these from real data immediately. Paste any of these to get going:

  • "Using the kalshiapi MCP tools, list 10 open Crypto markets and tell me which categories resolve YES most often."
  • "Call category_yes_rates and make a simple ranked table of YES-resolution rate by category, lowest to highest."
  • "Write a Python script that pulls hourly candles for a ticker I give you and flags when the price crosses 50 cents."

Keep it conversational. If the first answer isn't quite right, say "now only show markets closing this week" or "add the volume column." That back-and-forth is the whole vibe-coding loop: describe, run, refine.

Step 4: A tiny Python starter

Want to run something yourself right now? This ~15-line script uses the REST API and your free key. It lists a few markets, then pulls hourly candles for the first one. Save it as kalshi_bot.py, swap in your key, and run python kalshi_bot.py.

import requests

API = "https://kalshiapi.com"
HEADERS = {"X-API-Key": "YOUR_KEY"}  # from kalshiapi.com/#freekey

# 1) Grab a handful of markets
markets = requests.get(f"{API}/v1/markets", headers=HEADERS,
                       params={"limit": 5}).json()

for m in markets.get("markets", []):
    print(m.get("ticker"), "-", m.get("title"))

# 2) Pull hourly candles for the first market and flag the 50c line
ticker = markets["markets"][0]["ticker"]
candles = requests.get(f"{API}/v1/markets/{ticker}/candles",
                       headers=HEADERS).json()

for c in candles.get("candles", [])[:10]:
    price = c.get("close")
    flag = " <-- crossed 50c" if price and price >= 50 else ""
    print(ticker, c.get("ts"), price, flag)

If you've never run Python: install it from python.org, then run pip install requests once in your terminal. If a field name doesn't match what comes back, paste the error to your AI and it'll fix it in seconds, that's vibe-coding too.

Tip Stuck on an error? Copy the whole message and the script into your AI and say "this broke, here's the error, fix it and explain what was wrong." It's the fastest way to learn.

Step 5: Test on free data, then upgrade

Build and test everything on the free sample tier first. Once your bot does something you like, you'll want more data to make it real:

  • The full dataset covers 2.9M markets and hourly candles since 2023, plus 274M+ individual trades from the most recent months, across categories like Crypto, Sports, and Financials.
  • That depth is what makes proper backtesting possible: you can replay history to check whether your strategy would actually have worked before risking anything.

When you're ready, the pricing page has a monthly API plan and a one-time full historical download. Same endpoints, just higher limits and the complete history.

You're done. What now?

That's the whole loop: free key, connect your AI, prompt it, run a tiny script, then scale up when it earns its keep. From here you could have your AI add alerts, score markets by category, or build a simple dashboard. Go build something fun.