Kalshi Demo Environment Topology and What It Actually Exposes to a Staging Bot

Kalshi's demo validates signing, routing, and rate limits, not profits.

· 8 min read
Cover illustration for “Kalshi Demo Environment Topology and What It Actually Exposes to a Staging Bot”
Kalshi API Integration · November 14, 2026 · 8 min read · 1,756 words

A Kalshi bot needs separate tests for API correctness, order-flow logic, and how it behaves during live execution. Kalshi’s demo environment validates real signing, routing, rate limits, and state transitions, but not strategy profitability or production liquidity. A sound workflow uses a stateful simulator for repeatable CI tests, the demo for staging, and a limited-position production canary for behavior that neither can reproduce.

How Kalshi's demo environment is structured at the network and credential layer

Kalshi’s demo is a separate deployment. Its credentials, REST hostnames, and WebSocket URLs are distinct, while endpoint paths mirror production. Kalshi’s API environments documentation states that credentials are not shared between environments. A demo key gets a 401 from a production host, and a production key fails when used with demo. Credential isolation is absolute, even though both deployments implement the same authentication mechanism.

For REST clients, the recommended demo host is external-api.demo.kalshi.co, parallel to external-api.kalshi.com in production. The external-api hosts serve only the external Trade API, and legacy hosts still work. Standard demo WebSocket traffic uses wss://external-api-ws.demo.kalshi.co/trade-api/ws/v2. Host selection also determines which channels are available. A subscription sent to the wrong host class gets error code 8, Unknown channel name, even if the connection authenticated.

Fill and order updates have their own low-latency user channels. The documented demo addresses include wss://warp-ws.demo.kalshi.co/trade-api/ws/v2 for predictions and wss://margin-user-ws.demo.kalshi.co/trade-api/ws/v2/margin for margin. However, the deprecated warp-ws and margin-warp-ws hosts function only temporarily and should not be targets for new staging code. External feeds have their own address, wss://external-feeds.demo.kalshi.co/trade-api/v2/external-feeds, with existing feed URLs supported during migration.

Network isolation has a separate boundary. AWS PrivateLink is available on Premier tier and above for production REST and WebSocket hosts only. The environments documentation identifies external-api.kalshi.com and external-api-ws.kalshi.com as the provisioned hosts. There is no demo equivalent. A staging bot using public internet routing therefore cannot validate the PrivateLink path it will use after production cutover.

How request signing works and why it is identical across environments

Separate credentials do not mean a simplified authentication protocol. Demo uses the same signing code as production, so a staging bot must use real cryptographic authentication. Each request is authenticated with a timestamp-keyed signature derived from the HTTP method and path.

Kalshi’s API Keys documentation identifies Ed25519 as the default in the key creation dialog. RSA-PSS offers an alternative to Ed25519 for clients requiring it, using 2048-bit keys, SHA-256, MGF1 with SHA-256, and a salt length equal to the digest length.

The hostname is outside the signed payload. The environments documentation states, “The host does not change the signature payload. Sign the full request path from the API root, without query parameters”. Its canonical example is /trade-api/v2/portfolio/orders, regardless of the target host. Consequently, moving from external-api.demo.kalshi.co to external-api.kalshi.com changes the configured host and key values. The example’s legacy order mutation endpoint serves only to illustrate path construction.

Key handling remains part of this test. The private key PEM appears only once at creation, while the Key ID, a UUID, remains listed on the API Keys dashboard. Closing the dialog without saving the PEM requires regenerating the key. WebSocket connections also require API key authentication and the same signed connection setup as production.

What the demo exposes to a staging bot — the testable surface

A pre-production run can start by reading market data without credentials. Public endpoints cover series, events, markets, order books, trades, and candlesticks in both environments. These include GET /series, GET /events, GET /markets, GET /markets/{ticker}/orderbook, and GET /markets/trades. Live candlesticks use GET /series/{series_ticker}/markets/{ticker}/candlesticks, while historical candlesticks use GET /historical/markets/{ticker}/candlesticks. For a bot consuming settled-market data, endpoint selection is itself testable behavior.

Historical retrieval needs a distinct assertion. Older settled-market data moves to /historical/... endpoints and no longer appears on live endpoints. A bot polling the live surface for those markets can receive empty results without an error. That distinction belongs in staging because an empty response does not establish that the requested history does not exist. It also separates testing historical-data retrieval from evaluating the strategy that consumes that data.

Order handling provides the next concrete test. Demo supports creation, partial fill, full fill, cancellation, and conflict after completion. New orders use POST /portfolio/events/orders, CreateOrder V2. The legacy /portfolio/orders mutation endpoints were deprecated in June 2026, between June 18–25, and must not appear in staging bot code. Cancels should pass market_ticker so they route to the correct exchange shard.

Streaming tests cover order book deltas, tickers, trades, fills, and user_orders, including reconnection and subscription resumption. Host-routing failures are testable too. Rate-limit tests exercise the same token-bucket behavior, so a bot hitting 429s in demo will encounter them in production at the same request rate. These tests assess whether the client handles the API’s constraints.

Institutional clients can also test how the FIX protocol works. FIX uses FIXT.1.1 transport and application version FIX 5.0 SP2 over TLS 1.2 or higher, with plain TCP refused. Order entry uses port 8228 without retransmission or 8230 with retransmission, and market data uses port 8233. Six services cover order entry, market data, drop copy, RFQ, and post-trade settlement reports. FIX application messages draw from the same Read/Write buckets as equivalent REST operations, so changing protocols does not provide a separate rate-limit allowance.

What the demo withholds — the gaps that give staging bots false confidence

Demo fills, liquidity, and spreads do not reflect real market conditions. Kalshi’s documentation explicitly states that demo market behavior need not represent real-market behavior. That is a hard boundary on interpretation. A completed demo order demonstrates an exercised order path.

Strategy signal quality cannot be inferred from those fills. Demo markets may fill orders that would rest or reject in a thin live market, and the reverse can occur. Real price discovery and spread behavior are absent because the demo does not simulate other participants’ behavior. Passing integration tests cannot show how good a backtest is or take the place of real market microstructure when testing whether a strategy is profitable.

RFQ is unavailable on margin in both demo and production, so a margin bot cannot treat it as a feature that becomes testable after launch. PrivateLink presents a different constraint because the feature exists in production but has no demo path. A public-network staging result leaves that production-only configuration untested, a distinction that keeps unsupported product behavior and untested network behavior in separate categories.

The dedicated demo feed hostname is live, but clients using the legacy URL can continue connecting during the migration window. Both old and new feed Origins are accepted, and server-to-server clients may omit Origin entirely. A staging bot should explicitly test the new feed hostname before cutover.

Why stateful behavior in the demo matters and where stateless mocks fall short of it

The demo’s persistence is a genuine testing capability. An order created through the API persists, can be polled by ID, can partially fill, and can enter a state that blocks later operations. Each response depends on what happened before it. A stateless mock cannot reproduce that relationship because its fixtures do not hold the changing order.

Consider a create request returning a 201 and an order ID. The bot then polls that ID until the order is complete. A stateless fixture either repeats an incomplete status indefinitely or returns completion immediately, regardless of the bot’s preceding actions. Its returned ID may not correspond to the created order at all. Referential integrity between calls is absent, so the test does not establish that the bot follows the order it actually submitted.

Cancellation exposes the same structural gap. After completion, the expected cancel response is a 409, but a stateless mock never entered the completed state that makes that response appropriate. It can return a conflict fixture without testing the transition that caused the conflict. Position reconciliation has a similar failure mode. A fixture can report “position exists” before any fill, allowing reconciliation logic to pass against behavior the real API would reject.

Static tools return one response for each endpoint, while conditional tools choose a response based on what is in the request and cover many error paths without persistence. Stateful tools hold data between requests. Scripted tools let each request run any logic, but they can turn into a second version of the backend that needs to be maintained. The important selection criterion for order-flow testing is whether the tool preserves relationships and transitions across calls.

A well-verified stateful simulator occupies the same testing tier as demo for order lifecycles and state transitions. Its different role comes from where it runs. Running locally and offline needs no live credentials and uses none of the real rate-limit allowance, so integration tests can run again and again in CI. Demo is still where pre-production staging tests real authentication, routing, and network behavior. Neither layer replaces the other’s evidence.

How to test a Kalshi bot using the demo's real boundaries

The practical workflow assigns each concern to the layer capable of validating it. Demo tests should cover signing, host and channel routing, how rate limits work, and how WebSocket reconnection works under real network conditions. Deliberately triggering error code 8 tests the routing failure path. The new external feeds hostname also belongs in this staging run. When authentication fails, both signing and the credentials for that environment need to be checked, since even a valid key fails in the wrong environment.

Order transitions need testing at two layers. Demo exercises creation, polling, partial fill, completion, and cancel-after-complete conflict against a live stateful counterparty. A stateful simulator supplies deterministic regression coverage for the same order-flow logic in CI. Fault injection adds 429 handling, 503 recovery, latency spikes, and duplicate message delivery, which demo does not expose on demand. It also makes difficult timing cases repeatable, including a fill arriving after a cancel is submitted.

The CI sequence should preserve those distinct responsibilities. Static analysis comes first, then unit tests with mocked LLM/tool calls, then integration tests that use a stateful simulator with fault injection. Demo smoke tests then validate authentication and rate limits before evaluation gates on golden order-flow datasets. After those gates comes a production canary with a limited position size.

The pre-launch checklist should distinguish validated behavior, production-only behavior, and unavailable functionality. Signing, routing, state transitions, streaming recovery, and feed-host migration each need evidence from the appropriate test layer. Strategy signal quality, profitability, real liquidity, and spreads remain outside staging’s proof, while PrivateLink requires production-path validation. RFQ on margin belongs under unavailable functionality. A release decision can then rest on named evidence and explicit gaps rather than the undifferentiated claim that “demo passed”.

Sources

  1. API Environments and Endpoints - API Documentation

More in Kalshi API Integration