Kalshi API Guide (2026): Auth, Endpoints, WebSockets & Rate Limits
Many Kalshi API tutorials are out of date. They use the retired trading-api host, quote prices in cents, or show the old order payload with action and yes_price. If you copy one of them, you will get a 401 or a 400, then spend an afternoon debugging code that was correct two API revisions ago.
Everything below was checked against Kalshi’s v2 documentation in November 2026. It covers the hosts Kalshi recommends now, both supported key types, the exact signing string, the public market-data endpoints, the V2 order payload, WebSocket authentication, and the rate-limit math that matters when a bot runs continuously. Kalshi’s OpenAPI spec is the source of truth; if it disagrees with this guide, the spec wins.
What the Kalshi API gives you
Kalshi exposes three parts, and each has different authentication rules:
- Public market data: series, events, markets, order books, and trades. No API key required.
- Authenticated account data: balance, positions, orders, and fills. Requires a signed request.
- Order entry: creating, amending, and canceling orders. Requires a signed request and a funded account.
- WebSocket streams: live ticker, trades, order-book deltas, and user events. The handshake is authenticated even for public channels.
That split is useful for architecture. You can build a market scanner with no credentials at all, then add a signing layer only for the execution side. It also means a data-only agent never needs to handle a private key.
Base URLs and environments
Kalshi currently recommends the external-api hosts. The older api.elections.kalshi.com host still works and, despite the name, serves all markets rather than only election markets. New integrations should use the recommended hosts.
| Environment | REST (recommended) | WebSocket (recommended) |
|---|---|---|
| Production | https://external-api.kalshi.com/trade-api/v2 | wss://external-api-ws.kalshi.com/trade-api/ws/v2 |
| Demo | https://external-api.demo.kalshi.co/trade-api/v2 | wss://external-api-ws.demo.kalshi.co/trade-api/ws/v2 |
| Legacy production | https://api.elections.kalshi.com/trade-api/v2 | wss://api.elections.kalshi.com/trade-api/ws/v2 |
| Legacy demo | https://demo-api.kalshi.co/trade-api/v2 | wss://demo-api.kalshi.co/trade-api/ws/v2 |
Production and demo credentials are not interchangeable. A production key will not authenticate against the demo host, and a demo key will not authenticate against production. Keep the environment in a single configuration value so a test run cannot accidentally reach the live exchange.
There is also a lower-latency user WebSocket at wss://user-ws.kalshi.com/trade-api/ws/v2. It currently serves only the fill and user_orders channels. Everything else belongs on the standard WebSocket host.
Creating an API key
Sign in to Kalshi and open Account Settings, then Profile Settings, then API Keys, at kalshi.com/account/profile. Click Create New API Key. The dashboard now defaults to Ed25519; choose RSA only if your client cannot sign Ed25519.
You receive two things: a Key ID and a PEM private key. Kalshi does not retain the private key, and the download is shown once. Store it in a secret manager or an environment-injected file. Never put it in the repository or a container image layer.
| Key type | Signature | When to use it |
|---|---|---|
| Ed25519 | Ed25519 over the UTF-8 signing string | Default for new keys; smaller signatures and cheaper signing |
| RSA | RSA-PSS with SHA-256 | Clients and SDKs limited to RSA-PSS |
Do not infer the key type from the PEM header. A PKCS#8 RSA key generated with openssl genpkey can begin with -----BEGIN PRIVATE KEY-----, the same header an Ed25519 key uses. Parse the key and branch on its type, as the example below does.
Authentication: the exact signing string
Every authenticated REST request carries three headers:
| Header | Value |
|---|---|
KALSHI-ACCESS-KEY | Your Key ID |
KALSHI-ACCESS-TIMESTAMP | Unix time in milliseconds |
KALSHI-ACCESS-SIGNATURE | Base64-encoded signature |
The string you sign is a plain concatenation:
Three details break most signatures:
- The path includes
/trade-api/v2. If the full URL ishttps://external-api.kalshi.com/trade-api/v2/portfolio/balance, the signed path is/trade-api/v2/portfolio/balance, not/portfolio/balance. - The query string is stripped. Sign the path only. Adding
?limit=100to the signed string produces an invalid signature. - The timestamp is in milliseconds and must be fresh. Kalshi allows 30 seconds of clock skew. Generate the timestamp immediately before each request and keep the host on NTP.
For RSA, use RSA-PSS with SHA-256, MGF1 with SHA-256, and salt length equal to the digest length. For Ed25519, sign the same UTF-8 string directly. This Python example handles both key types and makes a real balance request:
If that returns 401, check the three signing details above before you touch the key. If it returns 403, the key is valid but the account or endpoint is not permitted for that action. Usually, a 401 is a cryptography or clock problem and a 403 is an account problem.
Public market data: no key required
Market discovery is open. These endpoints work without any authentication headers:
GET /trade-api/v2/series/{series_ticker}GET /trade-api/v2/markets?series_ticker={series_ticker}&status=openGET /trade-api/v2/events/{event_ticker}GET /trade-api/v2/markets/{market_ticker}/orderbook
GET /markets accepts filters for status (unopened, open, paused, closed, settled), series_ticker, event_ticker, tickers, close-time bounds, and a limit of up to 1,000. Responses paginate with a cursor; pass the cursor back until it is empty.
Price and size fields are fixed-point strings, not JSON numbers. A market response carries yes_bid_dollars, yes_ask_dollars, volume_fp, open_interest_fp, and close_time. Parse them with a decimal type. Doing binary arithmetic on floats is a slow way to discover that 0.56 plus 0.44 is not exactly 1.
The order-book endpoint has two traps. GET /markets/{ticker}/orderbook returns orderbook_fp.yes_dollars and orderbook_fp.no_dollars. Each level is [price_dollars, count_fp], arrays are sorted ascending, and the best bid is last. The API returns bids only, no asks. The best YES ask is the complement of the best NO bid, and vice versa. If you expect an asks array, you will conclude the book is empty when it is not.
Placing an order on the V2 API
The current order endpoint is POST /trade-api/v2/portfolio/events/orders. The V2 schema uses a single-book vocabulary: side: "bid" means buy YES, and side: "ask" means sell YES. This payload has no action, type, or yes_price fields.
Required fields are ticker, side, count, price, time_in_force, and self_trade_prevention_type. Time in force is one of fill_or_kill, good_till_canceled, or immediate_or_cancel. expiration_time is Unix seconds and is valid only with good_till_canceled. reduce_only is rejected unless the order is immediate_or_cancel.
Use client_order_id as an idempotency key. It can be up to 64 characters using letters, digits, and _ - : + = /. If your process crashes after sending an order but before recording the response, retrying with the same client order ID is how you avoid a duplicate position.
A 201 response means the order was accepted, not that it is resting. Inspect remaining_count and fill_count in the response, and reconcile against GET /portfolio/orders and GET /portfolio/orders?status=resting. To cancel, use DELETE /trade-api/v2/portfolio/events/orders/{order_id}. The cancel response includes reduced_by, the number of contracts that were still open at cancellation time.
WebSocket: authenticated handshake, public channels
Kalshi’s WebSocket authenticates during the HTTP upgrade, not with a JSON login message. Sign this exact string with the same key:
Send KALSHI-ACCESS-KEY, KALSHI-ACCESS-TIMESTAMP, and KALSHI-ACCESS-SIGNATURE as upgrade headers. Once the connection is open, subscribe with a JSON command:
Public market-data channels are ticker, trade, market_lifecycle_v2, and multivariate_market_lifecycle. Private channels are orderbook_delta, fill, market_positions, communications, order_group_updates, and user_orders. Public channels do not need channel-level authorization, but the connection itself still needs a signed handshake.
Market-filtered channels require market_ticker or market_tickers. One subscription per channel, and unsubscribe must include the subscription IDs in sids. For orderbook_delta, update_interval_ms accepts 0, 100, or 1000 and cannot be changed on an existing subscription. A single subscription can cover a large market set, but the documented ceiling is 500,000 markets, so keep one subscription per strategy or venue shard rather than one unbounded subscription.
Rate limits, in tokens rather than requests
Kalshi enforces separate read and write token buckets, shared by REST and FIX. Most requests cost 10 tokens. GET /account/endpoint_costs lists the non-default costs, and GET /account/limits reports your tier and bucket sizes.
| Tier | Read tokens/s | Write tokens/s |
|---|---|---|
| Basic | 200 | 100 |
| Advanced | 300 | 300 |
| Expert | 600 | 600 |
| Premier | 1,200 | 1,200 |
At Basic, 200 read tokens per second and 10 tokens per request give you roughly 20 reads per second, and 100 write tokens give you roughly 10 writes per second. Batching does not save tokens: 25 batched orders cost 250 tokens, and 25 batched cancels cost 50. Kalshi rejects the whole batch unless it fits in the bucket at once, so a large batch can fail even when the average rate looks fine.
GET /portfolio/balance has a separate bucket: one call per second on Basic and Advanced, five per second above that. Do not poll balance on every loop iteration unless your loop is slower than one second; cache it and refresh on a timer.
A throttled request returns HTTP 429 with code too_many_requests and no Retry-After header. Read X-RateLimit-Remaining, X-RateLimit-Limit, X-RateLimit-Reset, and X-RateLimit-Cost, then back off exponentially. Kalshi does not state a penalty period; the bucket refills. Also budget WebSocket connections separately: Basic, Advanced, and Expert allow 200 concurrent connections, rising to 1,000 on Prime and Prestige.
A bot architecture that survives production
A production Kalshi bot separates six concerns:
- Discover markets with the public REST endpoints, paginating with the cursor.
- Stream prices and book deltas over WebSocket instead of polling the REST order book.
- Decide in your own process, using decimal arithmetic and a risk check before every order.
- Execute with
client_order_ididempotency, then record the response before the next action. - Reconcile orders, fills, and positions on a timer. A WebSocket can disconnect, and a 201 is not a fill.
- Back off on 429 and reconnect with jitter on WebSocket errors, resubscribing from the last known sequence.
Start in the demo environment. It uses mock funds and separate keys, so you can test the signing path, the order lifecycle, cancellation, and your reconnect logic without live risk. Demo liquidity is thinner and prices may not match production, so treat it as an integration test rather than a strategy test. When you go live, start with a small position cap and a hard daily loss limit in the process, not in a dashboard you might not be watching.
Running the bot where Kalshi expects it
Correct API code does not fix the network your bot leaves from. Kalshi applies eligibility checks at the network layer, and bot operators consistently report that hosting ASNs such as AWS, Hetzner, DigitalOcean, and OVH are rejected even when the account is verified and eligible. The API key is fine; the egress IP is the problem.
A proxy does not create eligibility, and using one to misrepresent residency violates Kalshi’s terms. The legitimate case is narrower: you are a US resident with a verified account, and your bot runs on a server in Frankfurt or Singapore. Your account is in the right place, but your server is not. A country-matched residential exit restores the network origin your account is entitled to.
SOCKS5 is the right tool here because it carries both the REST calls and the long-lived WebSocket upgrade. Configure it once in the client session. With ProxyBase, country is a property of the session, not a string you embed in a username:
Two details matter for reliability. First, use socks5h:// rather than socks5://, so DNS resolution happens at the exit instead of on your server. Second, assert the exit country at session start. A wrong-country session caught at startup costs one request; the same session discovered mid-order costs a rejected trade at the worst moment. Use a sticky session, not a rotating one, for anything authenticated: an IP that changes between the book fetch and the order submission looks like an account takeover, not a trader.
Pre-launch checklist
- Use the
external-apihosts, not the retired trading-api host. - Parse the PEM and branch on Ed25519 vs RSA instead of trusting the header.
- Sign
timestamp_ms + METHOD + path_without_query, including/trade-api/v2. - Sync the clock with NTP and generate a fresh timestamp per request.
- Use decimal types for
*_dollarsand*_fpstrings. - Remember that the order book returns bids only; derive asks from the opposite side.
- Send
client_order_idand treat a 201 as accepted, not filled. - Cache balance; do not poll the balance bucket every loop.
- Test reconnect, resubscribe, 429, and cancel paths in the demo environment.
- Verify the egress country before trading, and keep one sticky session per venue.
Frequently Asked Questions
Is the Kalshi API free to use?
API access is included with a Kalshi account. Public market-data endpoints need no key. Authenticated endpoints require a key, and trading fees follow Kalshi’s normal fee schedule rather than a separate API charge.
Should I use an RSA or Ed25519 key?
Ed25519 is the default for new keys and the better choice for new integrations. Choose RSA only when your client or SDK requires RSA-PSS. The headers and signed string are identical for both.
Why does my request return 401 header_timestamp_expired?
The timestamp must be Unix milliseconds and within 30 seconds of Kalshi’s clock. A seconds-based value, a drifted clock, or a timestamp reused across requests will fail. Sync with NTP and generate the timestamp immediately before signing.
Why do I get HTTP 429 with no Retry-After header?
Read and write token buckets are separate, and most requests cost 10 tokens. A 429 means the relevant bucket is empty. Inspect the X-RateLimit-* headers and back off exponentially. Balance has its own one-call-per-second bucket on Basic and Advanced.
Do I need a proxy to use the Kalshi API?
You do not need one for public data, and it cannot manufacture eligibility. The common failure is an eligible account running on a server in the wrong country or on a hosting ASN. A country-matched residential SOCKS5 session fixes that mismatch and leaves your signing code unchanged.
Can I test a bot without risking real money?
Yes. Use the demo environment at https://external-api.demo.kalshi.co/trade-api/v2 with a separate demo account and key. Demo liquidity differs from production; use it for integration and failure-path testing, not strategy evaluation.
Running your Kalshi bot from a VPS that gets rejected? Get country-matched residential SOCKS5 credentials in minutes, pay per GB in crypto, no KYC. Keep the compute where it is cheap and put the network identity where Kalshi expects it.