pmxt-core 2.36.0 → 2.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -460,10 +460,14 @@ export declare abstract class PredictionMarketExchange {
460
460
  * Fetch the current order book (bids/asks) for a specific outcome.
461
461
  * Essential for calculating spread, depth, and execution prices.
462
462
  *
463
- * @param id - The Outcome ID (outcomeId)
463
+ * @param id - The Outcome ID (outcomeId) or market slug
464
+ * @param side - Optional 'yes' or 'no' to explicitly indicate the
465
+ * outcome side. Required for exchanges where the API returns a
466
+ * single orderbook per market (e.g. Limitless) and the caller
467
+ * passes a slug instead of a token ID.
464
468
  * @returns Current order book with bids and asks
465
469
  */
466
- fetchOrderBook(id: string): Promise<OrderBook>;
470
+ fetchOrderBook(id: string, side?: 'yes' | 'no'): Promise<OrderBook>;
467
471
  /**
468
472
  * Fetch raw trade history for a specific outcome.
469
473
  *
@@ -406,10 +406,14 @@ class PredictionMarketExchange {
406
406
  * Fetch the current order book (bids/asks) for a specific outcome.
407
407
  * Essential for calculating spread, depth, and execution prices.
408
408
  *
409
- * @param id - The Outcome ID (outcomeId)
409
+ * @param id - The Outcome ID (outcomeId) or market slug
410
+ * @param side - Optional 'yes' or 'no' to explicitly indicate the
411
+ * outcome side. Required for exchanges where the API returns a
412
+ * single orderbook per market (e.g. Limitless) and the caller
413
+ * passes a slug instead of a token ID.
410
414
  * @returns Current order book with bids and asks
411
415
  */
412
- async fetchOrderBook(id) {
416
+ async fetchOrderBook(id, side) {
413
417
  throw new Error("Method fetchOrderBook not implemented.");
414
418
  }
415
419
  /**
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/kalshi/Kalshi.yaml
3
- * Generated at: 2026-05-03T04:33:34.890Z
3
+ * Generated at: 2026-05-03T09:02:19.502Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const kalshiApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.kalshiApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/kalshi/Kalshi.yaml
6
- * Generated at: 2026-05-03T04:33:34.890Z
6
+ * Generated at: 2026-05-03T09:02:19.502Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.kalshiApiSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/limitless/Limitless.yaml
3
- * Generated at: 2026-05-03T04:33:34.936Z
3
+ * Generated at: 2026-05-03T09:02:19.560Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const limitlessApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.limitlessApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/limitless/Limitless.yaml
6
- * Generated at: 2026-05-03T04:33:34.936Z
6
+ * Generated at: 2026-05-03T09:02:19.560Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.limitlessApiSpec = {
@@ -28,7 +28,7 @@ export declare class LimitlessExchange extends PredictionMarketExchange {
28
28
  protected fetchMarketsImpl(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
29
29
  protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
30
30
  fetchOHLCV(id: string, params: OHLCVParams): Promise<PriceCandle[]>;
31
- fetchOrderBook(id: string): Promise<OrderBook>;
31
+ fetchOrderBook(id: string, side?: 'yes' | 'no'): Promise<OrderBook>;
32
32
  private isNoOutcome;
33
33
  fetchTrades(id: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
34
34
  fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]>;
@@ -129,14 +129,14 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
129
129
  const rawPrices = await this.fetcher.fetchRawOHLCV(slug, params);
130
130
  return this.normalizer.normalizeOHLCV(rawPrices, params);
131
131
  }
132
- async fetchOrderBook(id) {
132
+ async fetchOrderBook(id, side) {
133
133
  const slug = await this.resolveSlug(id);
134
134
  const rawOrderBook = await this.fetcher.fetchRawOrderBook(slug);
135
135
  const orderBook = this.normalizer.normalizeOrderBook(rawOrderBook, id);
136
136
  // The Limitless API always returns the Yes-side order book regardless
137
137
  // of which token is queried. If the caller asked for the No token,
138
138
  // flip: noBid = 1 - yesAsk, noAsk = 1 - yesBid.
139
- const isNoToken = await this.isNoOutcome(id, slug);
139
+ const isNoToken = side === 'no' || (!side && await this.isNoOutcome(id, slug));
140
140
  if (isNoToken) {
141
141
  return {
142
142
  bids: orderBook.asks.map((level) => ({ price: 1 - level.price, size: level.size }))
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/myriad/myriad.yaml
3
- * Generated at: 2026-05-03T04:33:34.948Z
3
+ * Generated at: 2026-05-03T09:02:19.578Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const myriadApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.myriadApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/myriad/myriad.yaml
6
- * Generated at: 2026-05-03T04:33:34.948Z
6
+ * Generated at: 2026-05-03T09:02:19.578Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.myriadApiSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/opinion/opinion-openapi.yaml
3
- * Generated at: 2026-05-03T04:33:34.953Z
3
+ * Generated at: 2026-05-03T09:02:19.583Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const opinionApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.opinionApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/opinion/opinion-openapi.yaml
6
- * Generated at: 2026-05-03T04:33:34.953Z
6
+ * Generated at: 2026-05-03T09:02:19.583Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.opinionApiSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketClobAPI.yaml
3
- * Generated at: 2026-05-03T04:33:34.896Z
3
+ * Generated at: 2026-05-03T09:02:19.515Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const polymarketClobSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.polymarketClobSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketClobAPI.yaml
6
- * Generated at: 2026-05-03T04:33:34.896Z
6
+ * Generated at: 2026-05-03T09:02:19.515Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketClobSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/Polymarket_Data_API.yaml
3
- * Generated at: 2026-05-03T04:33:34.913Z
3
+ * Generated at: 2026-05-03T09:02:19.531Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const polymarketDataSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.polymarketDataSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/Polymarket_Data_API.yaml
6
- * Generated at: 2026-05-03T04:33:34.913Z
6
+ * Generated at: 2026-05-03T09:02:19.531Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketDataSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketGammaAPI.yaml
3
- * Generated at: 2026-05-03T04:33:34.909Z
3
+ * Generated at: 2026-05-03T09:02:19.529Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const polymarketGammaSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.polymarketGammaSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketGammaAPI.yaml
6
- * Generated at: 2026-05-03T04:33:34.909Z
6
+ * Generated at: 2026-05-03T09:02:19.529Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketGammaSpec = {
@@ -34,8 +34,9 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.PolymarketFetcher = void 0;
37
+ const errors_1 = require("../../errors");
37
38
  const utils_1 = require("./utils");
38
- const errors_1 = require("./errors");
39
+ const errors_2 = require("./errors");
39
40
  /**
40
41
  * Coerce a value that should be a Date into an actual Date instance.
41
42
  * Handles strings (ISO 8601), epoch numbers (seconds or milliseconds),
@@ -84,7 +85,7 @@ class PolymarketFetcher {
84
85
  return this.fetchRawMarketsDefault(params);
85
86
  }
86
87
  catch (error) {
87
- throw errors_1.polymarketErrorMapper.mapError(error);
88
+ throw errors_2.polymarketErrorMapper.mapError(error);
88
89
  }
89
90
  }
90
91
  // ------------------------------------------------------------------------
@@ -106,7 +107,7 @@ class PolymarketFetcher {
106
107
  return this.fetchRawEventsDefault(params);
107
108
  }
108
109
  catch (error) {
109
- throw errors_1.polymarketErrorMapper.mapError(error);
110
+ throw errors_2.polymarketErrorMapper.mapError(error);
110
111
  }
111
112
  }
112
113
  // ------------------------------------------------------------------------
@@ -136,7 +137,7 @@ class PolymarketFetcher {
136
137
  return { history: data.history || [] };
137
138
  }
138
139
  catch (error) {
139
- throw errors_1.polymarketErrorMapper.mapError(error);
140
+ throw errors_2.polymarketErrorMapper.mapError(error);
140
141
  }
141
142
  }
142
143
  // ------------------------------------------------------------------------
@@ -148,7 +149,14 @@ class PolymarketFetcher {
148
149
  return data;
149
150
  }
150
151
  catch (error) {
151
- throw errors_1.polymarketErrorMapper.mapError(error);
152
+ const mapped = errors_2.polymarketErrorMapper.mapError(error);
153
+ // The CLOB returns a generic "order not found" for missing books,
154
+ // which the heuristic mapper mis-categorises as OrderNotFound.
155
+ // Normalise to NotFound so all venues behave the same for order-book lookups.
156
+ if (mapped instanceof errors_1.OrderNotFound) {
157
+ throw new errors_1.NotFound(`Order book not found: ${id}`, 'Polymarket');
158
+ }
159
+ throw mapped;
152
160
  }
153
161
  }
154
162
  // ------------------------------------------------------------------------
@@ -169,7 +177,7 @@ class PolymarketFetcher {
169
177
  return trades;
170
178
  }
171
179
  catch (error) {
172
- throw errors_1.polymarketErrorMapper.mapError(error);
180
+ throw errors_2.polymarketErrorMapper.mapError(error);
173
181
  }
174
182
  }
175
183
  async fetchRawMyTrades(params, walletAddress) {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/probable/probable.yaml
3
- * Generated at: 2026-05-03T04:33:34.941Z
3
+ * Generated at: 2026-05-03T09:02:19.570Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const probableApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.probableApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/probable/probable.yaml
6
- * Generated at: 2026-05-03T04:33:34.941Z
6
+ * Generated at: 2026-05-03T09:02:19.570Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.probableApiSpec = {
@@ -85,12 +85,17 @@
85
85
  ]
86
86
  },
87
87
  "fetchOrderBook": {
88
- "verb": "get",
88
+ "verb": "post",
89
89
  "args": [
90
90
  {
91
91
  "name": "id",
92
92
  "kind": "string",
93
93
  "optional": false
94
+ },
95
+ {
96
+ "name": "side",
97
+ "kind": "unknown",
98
+ "optional": true
94
99
  }
95
100
  ]
96
101
  },
@@ -630,16 +630,33 @@ paths:
630
630
  $ref: '#/components/schemas/PriceCandle'
631
631
  description: Fetch historical OHLCV (candlestick) price data for a specific market outcome.
632
632
  '/api/{exchange}/fetchOrderBook':
633
- get:
633
+ post:
634
634
  summary: Fetch Order Book
635
635
  operationId: fetchOrderBook
636
636
  parameters:
637
637
  - $ref: '#/components/parameters/ExchangeParam'
638
- - in: query
639
- name: id
640
- required: true
641
- schema:
642
- type: string
638
+ requestBody:
639
+ content:
640
+ application/json:
641
+ schema:
642
+ title: FetchOrderBookRequest
643
+ type: object
644
+ properties:
645
+ args:
646
+ type: array
647
+ minItems: 1
648
+ maxItems: 2
649
+ items:
650
+ oneOf:
651
+ - type: string
652
+ - type: string
653
+ enum:
654
+ - 'yes'
655
+ - 'no'
656
+ credentials:
657
+ $ref: '#/components/schemas/ExchangeCredentials'
658
+ required:
659
+ - args
643
660
  responses:
644
661
  '200':
645
662
  description: Fetch Order Book response
@@ -129,8 +129,8 @@ class ErrorMapper {
129
129
  */
130
130
  mapNotFoundError(message, data) {
131
131
  const lowerMessage = message.toLowerCase();
132
- // Detect order not found
133
- if (lowerMessage.includes('order')) {
132
+ // Detect order not found (but not "order book" — that's a different resource)
133
+ if (lowerMessage.includes('order') && !lowerMessage.includes('order book')) {
134
134
  // Try to extract order ID from message
135
135
  const orderIdMatch = message.match(/order[:\s]+([a-zA-Z0-9-]+)/i);
136
136
  const orderId = orderIdMatch ? orderIdMatch[1] : 'unknown';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmxt-core",
3
- "version": "2.36.0",
3
+ "version": "2.37.0",
4
4
  "description": "pmxt is a unified prediction market data API. The ccxt for prediction markets.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,8 +29,8 @@
29
29
  "test": "jest -c jest.config.js",
30
30
  "server": "tsx watch src/server/index.ts",
31
31
  "server:prod": "node dist/server/index.js",
32
- "generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=2.36.0,library=urllib3",
33
- "generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=2.36.0,supportsES6=true,typescriptThreePlus=true && node ../sdks/typescript/scripts/fix-generated.js",
32
+ "generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=2.37.0,library=urllib3",
33
+ "generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=2.37.0,supportsES6=true,typescriptThreePlus=true && node ../sdks/typescript/scripts/fix-generated.js",
34
34
  "fetch:openapi": "node scripts/fetch-openapi-specs.js",
35
35
  "extract:jsdoc": "node ../scripts/extract-jsdoc.js",
36
36
  "generate:docs": "npm run extract:jsdoc && node ../scripts/generate-api-docs.js",