Guide · checked November 26, 2026
How to use the Kalshi API
Kalshi runs a plain REST API. Market data is open to anyone, while your own account needs a key and a signature on every request. This guide covers which calls need a key, how to create one, how signing works, the rate limits, and the errors almost everyone hits first.
1. What works without a key
We called each REST endpoint below with no key on November 26, 2026. The first group answered; the second returned 401. Kalshi's API reference draws the same line.
No key needed:
GET /exchange/status
GET /markets GET /markets/{ticker}
GET /events/{event_ticker} GET /series/{series_ticker}
GET /markets/trades
GET /series/{series_ticker}/markets/{ticker}/candlesticks
GET /markets/{ticker}/orderbook
GET /historical/cutoff /historical/markets /historical/trades
Key required (your own account):
GET /portfolio/balance /portfolio/positions /portfolio/orders
GET /portfolio/fills /portfolio/settlements
GET /historical/fills /historical/orders /historical/positionsPlacing or cancelling orders needs a key with trading permission. The real-time WebSocket feed also needs a signed key, even for public channels such as ticker and trade.
2. Your first request
Kalshi's recommended production base URL is https://external-api.kalshi.com/trade-api/v2. The older host api.elections.kalshi.com still works the same way and, despite the name, serves every market. List today's open markets in one series, here the daily high temperature in New York City:
curl "https://external-api.kalshi.com/trade-api/v2/markets?series_ticker=KXHIGHNY&status=open"
Take a ticker from the response and read its order book:
curl "https://external-api.kalshi.com/trade-api/v2/markets/{ticker}/orderbook?depth=5"- Prices come back as dollar strings such as
yes_bid_dollarsandlast_price_dollars; contract counts are strings ending in_fpwith two decimals, such asvolume_fp. Parse them as decimals, not floats. - The order book arrives as
orderbook_fpwithyes_dollarsandno_dollars: bids only, each a[price, contracts]pair, sorted from low to high, so the best bid is the last one. A no bid at 0.40 is the same liquidity as a yes offer at 0.60. - List endpoints return a
cursor. Send it back with the same filters until it comes back empty./marketsand/markets/tradestakelimitup to 1000. - Market data responses are cached briefly and can lag the exchange by several seconds. For the live state of a book, use the WebSocket feed at
wss://external-api-ws.kalshi.com/trade-api/ws/v2.
3. Create an API key
- Log in to kalshi.com and open your account settings (Account & security; Kalshi's docs also call it Profile Settings).
- Find API Keys and create a new key. Give it read-only access unless you will trade from code.
- Kalshi shows the
Key IDand downloads the private key as a file. Save it: Kalshi does not keep a copy and cannot show it again.
- Keys made on the website are Ed25519 by default since October 1, 2026. Pick RSA if your client only supports RSA-PSS; Kalshi's official SDKs need version 3.31.0 or later for Ed25519.
- A read-only key can list your fills, settlements, positions, orders and balance. It cannot place orders or move money, which makes it the right key for analytics and for any tool you connect.
- You can also paste a public key you generated yourself, so the private key never leaves your machine.
- The demo environment (demo.kalshi.co, test money) needs its own account and its own keys. Demo keys only work against the demo API (
https://external-api.demo.kalshi.co/trade-api/v2).
4. Sign your requests
Every private request carries three headers:
KALSHI-ACCESS-KEY: your Key ID.KALSHI-ACCESS-TIMESTAMP: the current Unix time in milliseconds. It has to be within 30 seconds of Kalshi's clock.KALSHI-ACCESS-SIGNATURE: the base64 signature of timestamp + method + path, for example1764160000000GET/trade-api/v2/portfolio/fills. The path includes/trade-api/v2and leaves out the host and the query string.
Ed25519 keys sign that string directly. RSA keys use RSA-PSS with SHA-256, MGF1 with SHA-256, and a salt as long as the digest (32 bytes). A minimal Node.js version with no dependencies (save it as a .mjs file):
import crypto from "node:crypto";
import fs from "node:fs";
const KEY_ID = "your-key-id";
const privateKey = crypto.createPrivateKey(fs.readFileSync("kalshi-key.pem"));
const HOST = "https://external-api.kalshi.com";
function sign(message) {
const data = Buffer.from(message);
const signature = privateKey.asymmetricKeyType === "ed25519"
? crypto.sign(null, data, privateKey)
: crypto.sign("sha256", data, {
key: privateKey,
padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
saltLength: 32,
});
return signature.toString("base64");
}
async function kalshiGet(path, query = "") {
const ts = Date.now().toString();
const signature = sign(ts + "GET" + "/trade-api/v2" + path);
const res = await fetch(HOST + "/trade-api/v2" + path + query, {
headers: {
"KALSHI-ACCESS-KEY": KEY_ID,
"KALSHI-ACCESS-TIMESTAMP": ts,
"KALSHI-ACCESS-SIGNATURE": signature,
},
});
if (!res.ok) throw new Error(res.status + " " + (await res.text()));
return res.json();
}
const page = await kalshiGet("/portfolio/fills", "?limit=100");
console.log(page.fills.length, "fills, next cursor:", page.cursor);We checked this signing code against the signer FillBook runs every night: identical output for Ed25519 keys, and RSA-PSS signatures that verify with the same settings. Prefer Python? The trade history export guide has a full script that pages through every fill. Kalshi also publishes official SDKs (kalshi_python_sync, kalshi_python_async and kalshi-typescript) that sign for you.
5. Rate limits
Signed requests spend tokens from two buckets, one for reads and one for writes. On the Basic tier, which every account starts on, the buckets refill at 200 read and 100 write tokens per second. Most calls cost 10 tokens, so that is roughly 20 reads and 10 writes a second. Advanced needs an order placed through the API plus a call to the upgrade endpoint, and the tiers above it are earned with trading volume. GET /account/limits shows your tier. Unauthenticated market-data calls are limited per IP address instead, and Kalshi does not publish those numbers.
Going over returns HTTP 429 with the error code too_many_requests. There is no Retry-After header, so wait with exponential backoff and try again. Some signed responses carry X-RateLimit-Remaining and X-RateLimit-Reset headers; cached market data carries none. Rate limits as listed on Kalshi's docs on November 26, 2026.
6. Errors you will hit
- 401 on a private endpoint. With no headers at all the error code is
token_authentication_failure. With headers, check the signed string: query string left in,/trade-api/v2missing, seconds instead of milliseconds, a clock more than 30 seconds off (header_timestamp_expired), a Key ID from a different key, or a demo key sent to production. - 403 insufficient_scope. The key works but lacks the permission, for example a read-only key placing an order. The error code names the scope it needs.
- 400 on a time filter. On trades and candlesticks,
min_ts,max_ts,start_tsandend_tstake Unix seconds. Millisecond values are rejected. - A paging loop that never ends. On
/markets,/historical/marketsand/markets/tradesa cursor that cannot be decoded, such as a truncated one, is ignored and you get the first page again. Stop if a cursor repeats. - 404, or an empty list, for an older market. Settled markets move to an archive once they pass a moving cutoff. In our check a January 2025 market returned 404 on
/markets/{ticker}, and/markets/tradesreturned an empty list for it instead of an error, while/historical/tradeshad its trades. Call/historical/cutoffto see where the line sits (on November 26, 2026: September 27, 2026 for settled markets and trades). - Fills missing from your history. Your own fills are split the same way:
/portfolio/fillsreturns the recent part and the rest is at/historical/fills. Read both and remove duplicates by fill id.
Where to go next
- Kalshi order book and historical data: trades, candlesticks and the archive endpoints in more detail, with a Python loop.
- Export your Kalshi trade history: the CSV route and a Python script for your fills.
- Kalshi historical data download: hourly and daily price history for any market as a CSV: no code, no API key, no account.
Only after your own results? FillBook connects with a read-only key, pulls every fill and settlement, and shows realized P&L after fees, win rate by category and where your edge is. See the live demo →
FAQ
- Do I need an API key to use the Kalshi API?
- Not for market data over REST. Markets, events, series, trades, candlesticks, the order book and the archived market endpoints all answered without a key in our check on November 26, 2026, and Kalshi's API reference lists them without authentication. You need a key for your own account (balance, positions, orders, fills, settlements), for placing orders, and for the WebSocket feed.
- How do I get a Kalshi API key?
- Log in to kalshi.com, open your account settings (Account & security), find API Keys and create a new key. Give it read-only access unless you will trade from code. Kalshi shows a Key ID and downloads the private key as a file. Save the file: Kalshi does not keep a copy.
- What is the Kalshi API base URL?
- Kalshi recommends https://external-api.kalshi.com/trade-api/v2 for production REST calls. The older host api.elections.kalshi.com still works and is signed the same way. The demo environment is https://external-api.demo.kalshi.co/trade-api/v2, with its own account and its own keys.
- How do I sign a Kalshi API request?
- Send KALSHI-ACCESS-KEY (your Key ID), KALSHI-ACCESS-TIMESTAMP (Unix time in milliseconds) and KALSHI-ACCESS-SIGNATURE. The signature is the base64 of the timestamp, the HTTP method and the path joined into one string, with /trade-api/v2 included and the host and query string left out. Ed25519 keys sign that string directly; RSA keys use RSA-PSS with SHA-256 and a 32-byte salt.
- Why does the Kalshi API return 401?
- The request reached a private endpoint without a valid signature. The usual causes: the query string was included in the signed path, the /trade-api/v2 prefix was left out, the timestamp was in seconds or more than 30 seconds off Kalshi's clock, the Key ID and private key do not belong together, or a demo key was sent to production.
- What are the Kalshi API rate limits?
- Authenticated calls draw from token buckets. On the Basic tier you get 200 read and 100 write tokens per second and most calls cost 10, so roughly 20 reads and 10 writes a second (Kalshi's rate limit page, November 26, 2026). Unauthenticated market data has separate per-IP limits that Kalshi does not publish. Going over returns HTTP 429 with no Retry-After header, so back off exponentially.
- Does the Kalshi WebSocket need an API key?
- Yes. The WebSocket handshake needs the same three signed headers as REST, even if you only subscribe to public channels such as ticker and trade. Sign the path /trade-api/ws/v2.
Checked against live API responses and Kalshi's docs on November 26, 2026. Not affiliated with Kalshi; always confirm against docs.kalshi.com. Building a product on Kalshi data? Read Kalshi's developer agreement first.