pmxt-core 2.17.0 → 2.17.2

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.
@@ -60,7 +60,11 @@ class PredictionMarketExchange {
60
60
  constructor(credentials, options) {
61
61
  this.credentials = credentials;
62
62
  this._snapshotTTL = options?.snapshotTTL ?? 0;
63
- this.http = axios_1.default.create();
63
+ this.http = axios_1.default.create({
64
+ headers: {
65
+ 'User-Agent': `pmxt (https://github.com/pmxt-dev/pmxt)`
66
+ }
67
+ });
64
68
  this._throttler = new throttler_1.Throttler({
65
69
  refillRate: 1 / this._rateLimit,
66
70
  capacity: 1,
@@ -16,17 +16,21 @@ async function fetchEvents(connection, params) {
16
16
  status: params.status,
17
17
  searchIn: params.searchIn,
18
18
  });
19
- return markets.map(m => ({
20
- id: m.marketId,
21
- title: m.title,
22
- description: m.description,
23
- slug: m.marketId,
24
- markets: [m],
25
- url: m.url,
26
- image: m.image,
27
- category: m.category,
28
- tags: m.tags,
29
- }));
19
+ return markets.map(m => {
20
+ const unifiedEvent = {
21
+ id: m.marketId,
22
+ title: m.title,
23
+ description: m.description,
24
+ slug: m.marketId,
25
+ markets: [m],
26
+ url: m.url,
27
+ image: m.image,
28
+ category: m.category,
29
+ tags: m.tags,
30
+ };
31
+ m.event = unifiedEvent;
32
+ return unifiedEvent;
33
+ });
30
34
  }
31
35
  catch (error) {
32
36
  throw errors_1.baoziErrorMapper.mapError(error);
@@ -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-02-24T10:20:38.358Z
3
+ * Generated at: 2026-02-24T11:57:32.958Z
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-02-24T10:20:38.358Z
6
+ * Generated at: 2026-02-24T11:57:32.958Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.kalshiApiSpec = {
@@ -32,6 +32,9 @@ async function fetchEventByTicker(eventTicker, callApi) {
32
32
  category: event.category,
33
33
  tags: event.tags || [],
34
34
  };
35
+ for (const market of markets) {
36
+ market.event = unifiedEvent;
37
+ }
35
38
  return [unifiedEvent];
36
39
  }
37
40
  function rawEventToUnified(event) {
@@ -44,7 +47,7 @@ function rawEventToUnified(event) {
44
47
  }
45
48
  }
46
49
  }
47
- return {
50
+ const unifiedEvent = {
48
51
  id: event.event_ticker,
49
52
  title: event.title,
50
53
  description: event.mututals_description || "",
@@ -55,6 +58,10 @@ function rawEventToUnified(event) {
55
58
  category: event.category,
56
59
  tags: event.tags || [],
57
60
  };
61
+ for (const market of markets) {
62
+ market.event = unifiedEvent;
63
+ }
64
+ return unifiedEvent;
58
65
  }
59
66
  async function fetchAllWithStatus(callApi, apiStatus) {
60
67
  let allEvents = [];
@@ -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-02-24T10:20:38.402Z
3
+ * Generated at: 2026-02-24T11:57:33.000Z
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-02-24T10:20:38.402Z
6
+ * Generated at: 2026-02-24T11:57:33.000Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.limitlessApiSpec = {
@@ -1,3 +1,4 @@
1
1
  import { EventFetchParams } from '../../BaseExchange';
2
2
  import { UnifiedEvent } from '../../types';
3
- export declare function fetchEvents(params: EventFetchParams, callApi: (operationId: string, params?: Record<string, any>) => Promise<any>): Promise<UnifiedEvent[]>;
3
+ import { AxiosInstance } from 'axios';
4
+ export declare function fetchEvents(params: EventFetchParams, callApi: (operationId: string, params?: Record<string, any>) => Promise<any>, http?: AxiosInstance): Promise<UnifiedEvent[]>;
@@ -40,7 +40,7 @@ exports.fetchEvents = fetchEvents;
40
40
  const utils_1 = require("./utils");
41
41
  const errors_1 = require("./errors");
42
42
  const axios_1 = __importDefault(require("axios"));
43
- async function fetchEventBySlug(slug) {
43
+ async function fetchEventBySlug(slug, http = axios_1.default) {
44
44
  const { HttpClient, MarketFetcher } = await Promise.resolve().then(() => __importStar(require('@limitless-exchange/sdk')));
45
45
  const httpClient = new HttpClient({ baseURL: utils_1.LIMITLESS_API_URL });
46
46
  const marketFetcher = new MarketFetcher(httpClient);
@@ -58,7 +58,7 @@ async function fetchEventBySlug(slug) {
58
58
  if (unifiedMarket)
59
59
  marketsList = [unifiedMarket];
60
60
  }
61
- return {
61
+ const unifiedEvent = {
62
62
  id: market.slug,
63
63
  title: market.title || market.question,
64
64
  description: market.description || '',
@@ -69,6 +69,10 @@ async function fetchEventBySlug(slug) {
69
69
  category: market.categories?.[0],
70
70
  tags: market.tags || []
71
71
  };
72
+ for (const m of marketsList) {
73
+ m.event = unifiedEvent;
74
+ }
75
+ return unifiedEvent;
72
76
  }
73
77
  function rawMarketToEvent(market) {
74
78
  let marketsList = [];
@@ -82,7 +86,7 @@ function rawMarketToEvent(market) {
82
86
  if (unifiedMarket)
83
87
  marketsList = [unifiedMarket];
84
88
  }
85
- return {
89
+ const unifiedEvent = {
86
90
  id: market.slug,
87
91
  title: market.title || market.question,
88
92
  description: market.description || '',
@@ -93,13 +97,17 @@ function rawMarketToEvent(market) {
93
97
  category: market.categories?.[0],
94
98
  tags: market.tags || []
95
99
  };
100
+ for (const m of marketsList) {
101
+ m.event = unifiedEvent;
102
+ }
103
+ return unifiedEvent;
96
104
  }
97
- async function fetchEvents(params, callApi) {
105
+ async function fetchEvents(params, callApi, http = axios_1.default) {
98
106
  try {
99
107
  // Handle eventId/slug lookup (same thing for Limitless)
100
108
  if (params.eventId || params.slug) {
101
109
  const slug = params.eventId || params.slug;
102
- const event = await fetchEventBySlug(slug);
110
+ const event = await fetchEventBySlug(slug, http);
103
111
  return event ? [event] : [];
104
112
  }
105
113
  // Query-based search: use the /markets/search endpoint
@@ -108,7 +116,7 @@ async function fetchEvents(params, callApi) {
108
116
  }
109
117
  // Default: fetch active group markets from /markets/active
110
118
  // On Limitless, "events" = group markets (tradeType === 'group')
111
- return await fetchEventsDefault(params);
119
+ return await fetchEventsDefault(params, http);
112
120
  }
113
121
  catch (error) {
114
122
  throw errors_1.limitlessErrorMapper.mapError(error);
@@ -131,7 +139,7 @@ async function searchEvents(params, callApi) {
131
139
  }
132
140
  return markets.map(rawMarketToEvent);
133
141
  }
134
- async function fetchEventsDefault(params) {
142
+ async function fetchEventsDefault(params, http = axios_1.default) {
135
143
  // Limitless has no dedicated /events endpoint.
136
144
  // Group markets (tradeType === 'group') are the semantic equivalent of events.
137
145
  // We use GET /markets/active and filter for groups only.
@@ -141,7 +149,7 @@ async function fetchEventsDefault(params) {
141
149
  const MAX_PAGES = 40; // Safety cap
142
150
  const allGroups = [];
143
151
  while (allGroups.length < limit && page <= MAX_PAGES) {
144
- const response = await axios_1.default.get(`${utils_1.LIMITLESS_API_URL}/markets/active`, {
152
+ const response = await http.get(`${utils_1.LIMITLESS_API_URL}/markets/active`, {
145
153
  params: {
146
154
  page,
147
155
  limit: pageSize,
@@ -97,7 +97,7 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
97
97
  return (0, fetchMarkets_1.fetchMarkets)(params, apiKey, this.callApi.bind(this));
98
98
  }
99
99
  async fetchEventsImpl(params) {
100
- return (0, fetchEvents_1.fetchEvents)(params, this.callApi.bind(this));
100
+ return (0, fetchEvents_1.fetchEvents)(params, this.callApi.bind(this), this.http);
101
101
  }
102
102
  async fetchOHLCV(id, params) {
103
103
  return (0, fetchOHLCV_1.fetchOHLCV)(id, params, this.callApi.bind(this));
@@ -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-02-24T10:20:38.413Z
3
+ * Generated at: 2026-02-24T11:57:33.012Z
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-02-24T10:20:38.413Z
6
+ * Generated at: 2026-02-24T11:57:33.012Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.myriadApiSpec = {
@@ -89,7 +89,7 @@ function mapQuestionToEvent(question) {
89
89
  if (um)
90
90
  markets.push(um);
91
91
  }
92
- return {
92
+ const unifiedEvent = {
93
93
  id: String(question.id),
94
94
  title: question.title || '',
95
95
  description: '',
@@ -97,4 +97,8 @@ function mapQuestionToEvent(question) {
97
97
  markets,
98
98
  url: `https://myriad.markets`,
99
99
  };
100
+ for (const m of markets) {
101
+ m.event = unifiedEvent;
102
+ }
103
+ return unifiedEvent;
100
104
  }
@@ -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-02-24T10:20:38.367Z
3
+ * Generated at: 2026-02-24T11:57:32.965Z
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-02-24T10:20:38.367Z
6
+ * Generated at: 2026-02-24T11:57:32.965Z
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-02-24T10:20:38.384Z
3
+ * Generated at: 2026-02-24T11:57:32.981Z
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-02-24T10:20:38.384Z
6
+ * Generated at: 2026-02-24T11:57:32.981Z
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-02-24T10:20:38.380Z
3
+ * Generated at: 2026-02-24T11:57:32.978Z
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-02-24T10:20:38.380Z
6
+ * Generated at: 2026-02-24T11:57:32.978Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketGammaSpec = {
@@ -99,7 +99,9 @@ class PolymarketAuth {
99
99
  try {
100
100
  // Polymarket Data API / Profiles endpoint
101
101
  // Path-based: https://data-api.polymarket.com/profiles/0x...
102
- const response = await axios_1.default.get(`https://data-api.polymarket.com/profiles/${address}`);
102
+ const response = await axios_1.default.get(`https://data-api.polymarket.com/profiles/${address}`, {
103
+ headers: { 'User-Agent': 'pmxt (https://github.com/pmxt-dev/pmxt)' }
104
+ });
103
105
  const profile = response.data;
104
106
  // console.log(`[PolymarketAuth] Profile for ${address}:`, JSON.stringify(profile));
105
107
  if (profile && profile.proxyAddress) {
@@ -17,7 +17,7 @@ function mapRawEventToUnified(event) {
17
17
  }
18
18
  }
19
19
  }
20
- return {
20
+ const unifiedEvent = {
21
21
  id: event.id || event.slug,
22
22
  title: event.title,
23
23
  description: event.description || '',
@@ -28,6 +28,10 @@ function mapRawEventToUnified(event) {
28
28
  category: event.category || event.tags?.[0]?.label,
29
29
  tags: event.tags?.map((t) => t.label) || []
30
30
  };
31
+ for (const market of markets) {
32
+ market.event = unifiedEvent;
33
+ }
34
+ return unifiedEvent;
31
35
  }
32
36
  async function fetchEvents(params, http = axios_1.default) {
33
37
  try {
@@ -146,7 +146,7 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
146
146
  markets.push(unified);
147
147
  }
148
148
  }
149
- return {
149
+ const unifiedEvent = {
150
150
  id: event.id || event.slug,
151
151
  title: event.title,
152
152
  description: event.description || '',
@@ -157,6 +157,10 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
157
157
  category: event.category || event.tags?.[0]?.label,
158
158
  tags: event.tags?.map((t) => t.label) || [],
159
159
  };
160
+ for (const market of markets) {
161
+ market.event = unifiedEvent;
162
+ }
163
+ return unifiedEvent;
160
164
  });
161
165
  }
162
166
  return (0, fetchEvents_1.fetchEvents)(params, this.http);
@@ -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-02-24T10:20:38.408Z
3
+ * Generated at: 2026-02-24T11:57:33.006Z
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-02-24T10:20:38.408Z
6
+ * Generated at: 2026-02-24T11:57:33.006Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.probableApiSpec = {
@@ -57,7 +57,7 @@ function mapEventToUnified(event) {
57
57
  markets.push(mapped);
58
58
  }
59
59
  }
60
- return {
60
+ const unifiedEvent = {
61
61
  id: String(event.id),
62
62
  title: event.title || '',
63
63
  description: event.description || '',
@@ -68,6 +68,10 @@ function mapEventToUnified(event) {
68
68
  category: event.category || undefined,
69
69
  tags: event.tags || [],
70
70
  };
71
+ for (const market of markets) {
72
+ market.event = unifiedEvent;
73
+ }
74
+ return unifiedEvent;
71
75
  }
72
76
  async function enrichMarketsWithPrices(markets, callMidpoint) {
73
77
  const outcomes = [];
package/dist/types.d.ts CHANGED
@@ -37,6 +37,7 @@ export interface UnifiedMarket {
37
37
  category?: string;
38
38
  tags?: string[];
39
39
  tickSize?: number;
40
+ event?: UnifiedEvent;
40
41
  yes?: MarketOutcome;
41
42
  no?: MarketOutcome;
42
43
  up?: MarketOutcome;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmxt-core",
3
- "version": "2.17.0",
3
+ "version": "2.17.2",
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.17.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.17.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.17.2,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.17.2,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",