Skip to content

Commit e9d6bae

Browse files
committed
fix(kalshi): update API hostnames to external-api.kalshi.com
api.external-api.kalshi.com was decommissioned by Kalshi, breaking all ingest runs with ENOTFOUND for ~2.6 days. Updated all four URL constants in config.ts to the current hostnames and regenerated api.ts from the updated Kalshi.yaml spec.
1 parent 52f0769 commit e9d6bae

13 files changed

Lines changed: 49 additions & 46 deletions

File tree

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [2.49.9] - 2026-06-11
6+
7+
Kalshi API hostname fix. The `api.external-api.kalshi.com` domain was decommissioned by Kalshi, causing all Kalshi ingest runs to fail with `ENOTFOUND` for approximately 2.6 days. Updated all hardcoded URLs to the current hostnames.
8+
9+
### Fixed
10+
11+
- **`core/src/exchanges/kalshi/config.ts`**: Updated production REST base URL from `https://api.external-api.kalshi.com` to `https://external-api.kalshi.com`, demo REST from `https://demo-api.external-api.kalshi.com` to `https://external-api.demo.kalshi.co`, production WebSocket from `wss://api.external-api.kalshi.com/trade-api/ws/v2` to `wss://external-api-ws.kalshi.com/trade-api/ws/v2`, and demo WebSocket to `wss://external-api-ws.demo.kalshi.co/trade-api/ws/v2`. The `KALSHI_BASE_URL` and `KALSHI_DEMO_BASE_URL` env var overrides remain supported and take precedence over these defaults.
12+
- **`core/specs/kalshi/Kalshi.yaml`**: Replaced the `{env}.external-api.kalshi.com` server-variable entry with two explicit server entries matching the new hostnames. Regenerated `core/src/exchanges/kalshi/api.ts` from the updated spec.
13+
514
## [2.49.8] - 2026-06-10
615

716
Hosted trading quickstart actually works now. The SDKs' client-side economics validator was rejecting every server-built market order before signing (`economic mismatch: worst_price expected <= ... got 0.999`), because the hosted trading API deliberately pins market-order `worst_price` to the tick-grid extreme and caps the user with `max_cost_usdc` / `shares_6dec` instead ("textbook market semantics"). Verified live against `trade.pmxt.dev` with a real $5 fill end-to-end.

core/specs/kalshi/Kalshi.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,10 @@ info:
55
description: Manually defined OpenAPI spec for endpoints being migrated to spec-first approach
66

77
servers:
8-
- url: https://{env}.external-api.kalshi.com/trade-api/v2
9-
description: Kalshi Trade API
10-
variables:
11-
env:
12-
default: api
13-
enum:
14-
- api
15-
- demo-api
16-
description: >
17-
'api' = production environment.
18-
'demo-api' = demo environment.
8+
- url: https://external-api.kalshi.com/trade-api/v2
9+
description: Kalshi Trade API (production)
10+
- url: https://external-api.demo.kalshi.co/trade-api/v2
11+
description: Kalshi Trade API (demo)
1912

2013
paths:
2114
/historical/cutoff:

core/src/exchanges/kalshi/api.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Auto-generated from /opt/data/repos/pmxt/.worktrees/hermes-42dac47d/core/specs/kalshi/Kalshi.yaml
3-
* Generated at: 2026-06-05T12:40:10.068Z
2+
* Auto-generated from /Users/samueltinnerholm/Documents/GitHub/pmxt/core/specs/kalshi/Kalshi.yaml
3+
* Generated at: 2026-06-11T07:04:42.739Z
44
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
55
*/
66
export const kalshiApiSpec = {
@@ -11,16 +11,10 @@ export const kalshiApiSpec = {
1111
},
1212
"servers": [
1313
{
14-
"url": "https://{env}.external-api.kalshi.com/trade-api/v2",
15-
"variables": {
16-
"env": {
17-
"default": "api",
18-
"enum": [
19-
"api",
20-
"demo-api"
21-
]
22-
}
23-
}
14+
"url": "https://external-api.kalshi.com/trade-api/v2"
15+
},
16+
{
17+
"url": "https://external-api.demo.kalshi.co/trade-api/v2"
2418
}
2519
],
2620
"paths": {

core/src/exchanges/kalshi/config.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
* into core/src/exchanges/kalshi/api.ts by `npm run fetch:openapi`.
1111
* Do NOT put runtime config into api.ts — it will be overwritten.
1212
*
13-
* Environment mapping (aligns with the `{env}` server variable in Kalshi.yaml):
14-
* env = "api" → production: https://api.external-api.kalshi.com
15-
* env = "demo-api" → demo/paper: https://demo-api.external-api.kalshi.com
13+
* Environment mapping:
14+
* production: https://external-api.kalshi.com
15+
* demo/paper: https://external-api.demo.kalshi.co
1616
*/
1717

1818
// ── Base URL constants ────────────────────────────────────────────────────────
1919

20-
export const KALSHI_PROD_API_URL = process.env.KALSHI_BASE_URL || "https://api.external-api.kalshi.com";
21-
export const KALSHI_DEMO_API_URL = process.env.KALSHI_DEMO_BASE_URL || "https://demo-api.external-api.kalshi.com";
20+
export const KALSHI_PROD_API_URL = process.env.KALSHI_BASE_URL || "https://external-api.kalshi.com";
21+
export const KALSHI_DEMO_API_URL = process.env.KALSHI_DEMO_BASE_URL || "https://external-api.demo.kalshi.co";
2222

2323
export const KALSHI_PROD_WS_URL =
24-
"wss://api.external-api.kalshi.com/trade-api/ws/v2";
24+
"wss://external-api-ws.kalshi.com/trade-api/ws/v2";
2525
export const KALSHI_DEMO_WS_URL =
26-
"wss://demo-api.external-api.kalshi.com/trade-api/ws/v2";
26+
"wss://external-api-ws.demo.kalshi.co/trade-api/ws/v2";
2727

2828
// ── Path constants ────────────────────────────────────────────────────────────
2929

@@ -52,12 +52,12 @@ export interface KalshiApiConfig {
5252
/**
5353
* Return a typed config object for the requested environment.
5454
*
55-
* @param demoMode - Pass `true` to target demo-api.external-api.kalshi.com.
55+
* @param demoMode - Pass `true` to target external-api.demo.kalshi.co.
5656
*
5757
* @example
5858
* ```typescript
5959
* const config = getKalshiConfig(true);
60-
* // config.apiUrl === "https://demo-api.external-api.kalshi.com"
60+
* // config.apiUrl === "https://external-api.demo.kalshi.co"
6161
* ```
6262
*/
6363
export function getKalshiConfig(demoMode = false, baseUrlOverride?: string): KalshiApiConfig {

core/src/exchanges/limitless/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Auto-generated from /Users/ndmeiri/Developer/pmxt/core/specs/limitless/Limitless.yaml
3-
* Generated at: 2026-04-21T22:01:26.562Z
2+
* Auto-generated from /Users/samueltinnerholm/Documents/GitHub/pmxt/core/specs/limitless/Limitless.yaml
3+
* Generated at: 2026-06-11T07:04:42.757Z
44
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
55
*/
66
export const limitlessApiSpec = {

core/src/exchanges/myriad/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Auto-generated from /opt/data/repos/pmxt/.worktrees/hermes-42dac47d/core/specs/myriad/myriad.yaml
3-
* Generated at: 2026-06-05T12:40:10.188Z
2+
* Auto-generated from /Users/samueltinnerholm/Documents/GitHub/pmxt/core/specs/myriad/myriad.yaml
3+
* Generated at: 2026-06-11T07:04:42.763Z
44
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
55
*/
66
export const myriadApiSpec = {

core/src/exchanges/opinion/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Auto-generated from /opt/data/repos/pmxt/.worktrees/hermes-42dac47d/core/specs/opinion/opinion-openapi.yaml
3-
* Generated at: 2026-06-05T12:40:10.198Z
2+
* Auto-generated from /Users/samueltinnerholm/Documents/GitHub/pmxt/core/specs/opinion/opinion-openapi.yaml
3+
* Generated at: 2026-06-11T07:04:42.765Z
44
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
55
*/
66
export const opinionApiSpec = {

core/src/exchanges/polymarket/api-clob.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Auto-generated from /opt/data/repos/pmxt/.worktrees/hermes-42dac47d/core/specs/polymarket/PolymarketClobAPI.yaml
3-
* Generated at: 2026-06-05T12:40:10.090Z
2+
* Auto-generated from /Users/samueltinnerholm/Documents/GitHub/pmxt/core/specs/polymarket/PolymarketClobAPI.yaml
3+
* Generated at: 2026-06-11T07:04:42.744Z
44
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
55
*/
66
export const polymarketClobSpec = {

core/src/exchanges/polymarket/api-data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Auto-generated from /home/zihao/pmxt/core/specs/polymarket/Polymarket_Data_API.yaml
3-
* Generated at: 2026-05-10T23:00:51.410Z
2+
* Auto-generated from /Users/samueltinnerholm/Documents/GitHub/pmxt/core/specs/polymarket/Polymarket_Data_API.yaml
3+
* Generated at: 2026-06-11T07:04:42.750Z
44
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
55
*/
66
export const polymarketDataSpec = {

core/src/exchanges/polymarket/api-gamma.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Auto-generated from /home/zihao/pmxt/core/specs/polymarket/PolymarketGammaAPI.yaml
3-
* Generated at: 2026-05-10T23:00:51.408Z
2+
* Auto-generated from /Users/samueltinnerholm/Documents/GitHub/pmxt/core/specs/polymarket/PolymarketGammaAPI.yaml
3+
* Generated at: 2026-06-11T07:04:42.748Z
44
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
55
*/
66
export const polymarketGammaSpec = {

0 commit comments

Comments
 (0)