pmxt-core 2.34.3 → 2.35.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.
- package/dist/BaseExchange.d.ts +31 -0
- package/dist/BaseExchange.js +56 -0
- package/dist/exchanges/kalshi/api.d.ts +1 -1
- package/dist/exchanges/kalshi/api.js +1 -1
- package/dist/exchanges/kalshi/index.js +1 -1
- package/dist/exchanges/limitless/api.d.ts +1 -1
- package/dist/exchanges/limitless/api.js +1 -1
- package/dist/exchanges/limitless/fetcher.js +1 -1
- package/dist/exchanges/myriad/api.d.ts +1 -1
- package/dist/exchanges/myriad/api.js +1 -1
- package/dist/exchanges/opinion/api.d.ts +1 -1
- package/dist/exchanges/opinion/api.js +1 -1
- package/dist/exchanges/opinion/index.js +1 -1
- package/dist/exchanges/opinion/normalizer.js +10 -4
- package/dist/exchanges/polymarket/api-clob.d.ts +1 -1
- package/dist/exchanges/polymarket/api-clob.js +1 -1
- package/dist/exchanges/polymarket/api-data.d.ts +1 -1
- package/dist/exchanges/polymarket/api-data.js +1 -1
- package/dist/exchanges/polymarket/api-gamma.d.ts +1 -1
- package/dist/exchanges/polymarket/api-gamma.js +1 -1
- package/dist/exchanges/polymarket/fetcher.js +2 -2
- package/dist/exchanges/polymarket/index.js +1 -1
- package/dist/exchanges/probable/api.d.ts +1 -1
- package/dist/exchanges/probable/api.js +1 -1
- package/dist/exchanges/smarkets/index.js +1 -1
- package/dist/server/method-verbs.json +10 -0
- package/dist/server/openapi.yaml +57 -0
- package/package.json +3 -3
package/dist/BaseExchange.d.ts
CHANGED
|
@@ -273,6 +273,15 @@ export interface PaginatedMarketsResult {
|
|
|
273
273
|
/** Cursor to pass to the next call, or undefined if this is the last page */
|
|
274
274
|
nextCursor?: string;
|
|
275
275
|
}
|
|
276
|
+
/** Shape returned by fetchEventsPaginated */
|
|
277
|
+
export interface PaginatedEventsResult {
|
|
278
|
+
/** The page of unified events */
|
|
279
|
+
data: UnifiedEvent[];
|
|
280
|
+
/** Total number of events in the snapshot */
|
|
281
|
+
total: number;
|
|
282
|
+
/** Cursor to pass to the next call, or undefined if this is the last page */
|
|
283
|
+
nextCursor?: string;
|
|
284
|
+
}
|
|
276
285
|
export declare abstract class PredictionMarketExchange {
|
|
277
286
|
[key: string]: any;
|
|
278
287
|
verbose: boolean;
|
|
@@ -301,6 +310,7 @@ export declare abstract class PredictionMarketExchange {
|
|
|
301
310
|
private _throttler;
|
|
302
311
|
private _snapshotTTL;
|
|
303
312
|
private _snapshot?;
|
|
313
|
+
private _eventSnapshot?;
|
|
304
314
|
private apiDescriptors;
|
|
305
315
|
constructor(credentials?: ExchangeCredentials, options?: ExchangeOptions);
|
|
306
316
|
private _rateLimit;
|
|
@@ -365,6 +375,27 @@ export declare abstract class PredictionMarketExchange {
|
|
|
365
375
|
cursor?: string;
|
|
366
376
|
filter?: MarketFilterCriteria;
|
|
367
377
|
}): Promise<PaginatedMarketsResult>;
|
|
378
|
+
/**
|
|
379
|
+
* Paginated variant of {@link fetchEvents}.
|
|
380
|
+
*
|
|
381
|
+
* On the first call (no `cursor`), all events are fetched from the exchange
|
|
382
|
+
* and cached in an in-memory snapshot. A cursor is returned along with the
|
|
383
|
+
* first page. Subsequent calls with that cursor serve additional pages
|
|
384
|
+
* directly from the cached snapshot -- no additional API calls are made.
|
|
385
|
+
*
|
|
386
|
+
* The snapshot is invalidated after `snapshotTTL` ms (configured via `ExchangeOptions`
|
|
387
|
+
* in the constructor). A request using a cursor from an expired snapshot throws
|
|
388
|
+
* `'Cursor has expired'`.
|
|
389
|
+
*
|
|
390
|
+
* @param params.limit - Page size (default: return all events)
|
|
391
|
+
* @param params.cursor - Opaque cursor returned by a previous call
|
|
392
|
+
* @returns PaginatedEventsResult with data, total, and optional nextCursor
|
|
393
|
+
*/
|
|
394
|
+
fetchEventsPaginated(params?: {
|
|
395
|
+
limit?: number;
|
|
396
|
+
cursor?: string;
|
|
397
|
+
filter?: EventFilterCriteria;
|
|
398
|
+
}): Promise<PaginatedEventsResult>;
|
|
368
399
|
/**
|
|
369
400
|
* Fetch events with optional keyword search.
|
|
370
401
|
* Events group related markets together (e.g., "Who will be Fed Chair?" contains multiple candidate markets).
|
package/dist/BaseExchange.js
CHANGED
|
@@ -46,6 +46,7 @@ class PredictionMarketExchange {
|
|
|
46
46
|
// Snapshot state for cursor-based pagination
|
|
47
47
|
_snapshotTTL;
|
|
48
48
|
_snapshot;
|
|
49
|
+
_eventSnapshot;
|
|
49
50
|
apiDescriptors = [];
|
|
50
51
|
constructor(credentials, options) {
|
|
51
52
|
this.credentials = credentials;
|
|
@@ -254,6 +255,61 @@ class PredictionMarketExchange {
|
|
|
254
255
|
const nextCursor = limit < markets.length ? `${this._snapshot.id}:${limit}` : undefined;
|
|
255
256
|
return { data: applyFilter(slice), total: markets.length, nextCursor };
|
|
256
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Paginated variant of {@link fetchEvents}.
|
|
260
|
+
*
|
|
261
|
+
* On the first call (no `cursor`), all events are fetched from the exchange
|
|
262
|
+
* and cached in an in-memory snapshot. A cursor is returned along with the
|
|
263
|
+
* first page. Subsequent calls with that cursor serve additional pages
|
|
264
|
+
* directly from the cached snapshot -- no additional API calls are made.
|
|
265
|
+
*
|
|
266
|
+
* The snapshot is invalidated after `snapshotTTL` ms (configured via `ExchangeOptions`
|
|
267
|
+
* in the constructor). A request using a cursor from an expired snapshot throws
|
|
268
|
+
* `'Cursor has expired'`.
|
|
269
|
+
*
|
|
270
|
+
* @param params.limit - Page size (default: return all events)
|
|
271
|
+
* @param params.cursor - Opaque cursor returned by a previous call
|
|
272
|
+
* @returns PaginatedEventsResult with data, total, and optional nextCursor
|
|
273
|
+
*/
|
|
274
|
+
async fetchEventsPaginated(params) {
|
|
275
|
+
const limit = params?.limit;
|
|
276
|
+
const cursor = params?.cursor;
|
|
277
|
+
const filter = params?.filter;
|
|
278
|
+
const applyFilter = (events) => filter ? this.filterEvents(events, filter) : events;
|
|
279
|
+
if (cursor) {
|
|
280
|
+
const sep = cursor.indexOf(':');
|
|
281
|
+
const snapshotId = cursor.substring(0, sep);
|
|
282
|
+
const offset = parseInt(cursor.substring(sep + 1), 10);
|
|
283
|
+
if (!this._eventSnapshot ||
|
|
284
|
+
this._eventSnapshot.id !== snapshotId ||
|
|
285
|
+
(this._snapshotTTL > 0 && Date.now() - this._eventSnapshot.takenAt > this._snapshotTTL)) {
|
|
286
|
+
throw new Error('Cursor has expired');
|
|
287
|
+
}
|
|
288
|
+
const events = this._eventSnapshot.events;
|
|
289
|
+
const slice = limit !== undefined ? events.slice(offset, offset + limit) : events.slice(offset);
|
|
290
|
+
const nextOffset = offset + slice.length;
|
|
291
|
+
const nextCursor = nextOffset < events.length ? `${snapshotId}:${nextOffset}` : undefined;
|
|
292
|
+
return { data: applyFilter(slice), total: events.length, nextCursor };
|
|
293
|
+
}
|
|
294
|
+
// No cursor -- (re)fetch snapshot
|
|
295
|
+
if (!this._eventSnapshot ||
|
|
296
|
+
this._snapshotTTL === 0 ||
|
|
297
|
+
Date.now() - this._eventSnapshot.takenAt > this._snapshotTTL) {
|
|
298
|
+
const events = await this.fetchEventsImpl({});
|
|
299
|
+
this._eventSnapshot = {
|
|
300
|
+
events,
|
|
301
|
+
takenAt: Date.now(),
|
|
302
|
+
id: Math.random().toString(36).slice(2),
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
const events = this._eventSnapshot.events;
|
|
306
|
+
if (!limit) {
|
|
307
|
+
return { data: applyFilter(events), total: events.length, nextCursor: undefined };
|
|
308
|
+
}
|
|
309
|
+
const slice = events.slice(0, limit);
|
|
310
|
+
const nextCursor = limit < events.length ? `${this._eventSnapshot.id}:${limit}` : undefined;
|
|
311
|
+
return { data: applyFilter(slice), total: events.length, nextCursor };
|
|
312
|
+
}
|
|
257
313
|
/**
|
|
258
314
|
* Fetch events with optional keyword search.
|
|
259
315
|
* Events group related markets together (e.g., "Who will be Fed Chair?" contains multiple candidate markets).
|
|
@@ -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-04-
|
|
3
|
+
* Generated at: 2026-04-24T17:30:19.664Z
|
|
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-04-
|
|
6
|
+
* Generated at: 2026-04-24T17:30:19.664Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.kalshiApiSpec = {
|
|
@@ -105,7 +105,7 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
105
105
|
}
|
|
106
106
|
async fetchEventsImpl(params) {
|
|
107
107
|
const rawEvents = await this.fetcher.fetchRawEvents(params);
|
|
108
|
-
const limit = params?.limit ||
|
|
108
|
+
const limit = params?.limit || 250000;
|
|
109
109
|
const query = (params?.query || '').toLowerCase();
|
|
110
110
|
const filtered = query
|
|
111
111
|
? rawEvents.filter((event) => (event.title || '').toLowerCase().includes(query))
|
|
@@ -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-04-
|
|
3
|
+
* Generated at: 2026-04-24T17:30:19.700Z
|
|
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-04-
|
|
6
|
+
* Generated at: 2026-04-24T17:30:19.700Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.limitlessApiSpec = {
|
|
@@ -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-04-
|
|
3
|
+
* Generated at: 2026-04-24T17:30:19.712Z
|
|
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-04-
|
|
6
|
+
* Generated at: 2026-04-24T17:30:19.712Z
|
|
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-04-
|
|
3
|
+
* Generated at: 2026-04-24T17:30:19.717Z
|
|
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-04-
|
|
6
|
+
* Generated at: 2026-04-24T17:30:19.717Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.opinionApiSpec = {
|
|
@@ -148,7 +148,7 @@ class OpinionExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
148
148
|
}
|
|
149
149
|
async fetchEventsImpl(params) {
|
|
150
150
|
const rawEvents = await this.fetcher.fetchRawEvents(params);
|
|
151
|
-
const limit = params.limit ||
|
|
151
|
+
const limit = params.limit || 250000;
|
|
152
152
|
const query = (params.query || '').toLowerCase();
|
|
153
153
|
const filtered = query
|
|
154
154
|
? rawEvents.filter((raw) => (raw.marketTitle || '').toLowerCase().includes(query))
|
|
@@ -30,8 +30,14 @@ class OpinionNormalizer {
|
|
|
30
30
|
// Categorical: each child market becomes a separate UnifiedMarket
|
|
31
31
|
const children = raw.childMarkets || [];
|
|
32
32
|
const results = [];
|
|
33
|
+
const parentVolume24h = (0, utils_1.parseNumStr)(raw.volume24h);
|
|
34
|
+
const totalChildVolume = children.reduce((sum, c) => sum + (0, utils_1.parseNumStr)(c.volume), 0);
|
|
33
35
|
for (const child of children) {
|
|
34
|
-
const
|
|
36
|
+
const childVolume = (0, utils_1.parseNumStr)(child.volume);
|
|
37
|
+
const childVolume24h = totalChildVolume > 0
|
|
38
|
+
? (childVolume / totalChildVolume) * parentVolume24h
|
|
39
|
+
: 0;
|
|
40
|
+
const market = this.normalizeChildMarket(child, raw, childVolume24h);
|
|
35
41
|
if (market)
|
|
36
42
|
results.push(market);
|
|
37
43
|
}
|
|
@@ -202,7 +208,7 @@ class OpinionNormalizer {
|
|
|
202
208
|
(0, market_utils_1.addBinaryOutcomes)(market);
|
|
203
209
|
return market;
|
|
204
210
|
}
|
|
205
|
-
normalizeChildMarket(child, parent) {
|
|
211
|
+
normalizeChildMarket(child, parent, volume24h = 0) {
|
|
206
212
|
if (!child)
|
|
207
213
|
return null;
|
|
208
214
|
const marketId = String(child.marketId);
|
|
@@ -230,8 +236,8 @@ class OpinionNormalizer {
|
|
|
230
236
|
title: child.marketTitle || '',
|
|
231
237
|
description: child.rules || '',
|
|
232
238
|
outcomes: [yesOutcome, noOutcome],
|
|
233
|
-
resolutionDate: new Date((0, utils_1.toMillis)(child.cutoffAt
|
|
234
|
-
volume24h
|
|
239
|
+
resolutionDate: new Date((0, utils_1.toMillis)(child.cutoffAt)),
|
|
240
|
+
volume24h,
|
|
235
241
|
volume: (0, utils_1.parseNumStr)(child.volume),
|
|
236
242
|
liquidity: 0,
|
|
237
243
|
url: `https://opinion.trade/market/${child.marketId}`,
|
|
@@ -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-04-
|
|
3
|
+
* Generated at: 2026-04-24T17:30:19.671Z
|
|
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-04-
|
|
6
|
+
* Generated at: 2026-04-24T17:30:19.671Z
|
|
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-04-
|
|
3
|
+
* Generated at: 2026-04-24T17:30:19.683Z
|
|
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-04-
|
|
6
|
+
* Generated at: 2026-04-24T17:30:19.683Z
|
|
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-04-
|
|
3
|
+
* Generated at: 2026-04-24T17:30:19.681Z
|
|
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-04-
|
|
6
|
+
* Generated at: 2026-04-24T17:30:19.681Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketGammaSpec = {
|
|
@@ -284,7 +284,7 @@ class PolymarketFetcher {
|
|
|
284
284
|
// Private helpers -- Events
|
|
285
285
|
// ------------------------------------------------------------------------
|
|
286
286
|
async fetchRawEventsSearch(params) {
|
|
287
|
-
const limit = params.limit ||
|
|
287
|
+
const limit = params.limit || 25000;
|
|
288
288
|
let sortParam = 'volume';
|
|
289
289
|
if (params.sort === 'newest')
|
|
290
290
|
sortParam = 'startDate';
|
|
@@ -339,7 +339,7 @@ class PolymarketFetcher {
|
|
|
339
339
|
}).slice(0, limit);
|
|
340
340
|
}
|
|
341
341
|
async fetchRawEventsDefault(params) {
|
|
342
|
-
const limit = params.limit ||
|
|
342
|
+
const limit = params.limit || 25000;
|
|
343
343
|
const status = params.status || 'active';
|
|
344
344
|
let sortParam = 'volume';
|
|
345
345
|
if (params.sort === 'newest')
|
|
@@ -516,7 +516,7 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
516
516
|
return rawEvents
|
|
517
517
|
.map((raw) => this.normalizer.normalizeEvent(raw))
|
|
518
518
|
.filter((e) => e !== null)
|
|
519
|
-
.slice(0, params.limit ||
|
|
519
|
+
.slice(0, params.limit || 250000);
|
|
520
520
|
}
|
|
521
521
|
/**
|
|
522
522
|
* Ensure authentication is initialized before trading operations.
|
|
@@ -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-04-
|
|
3
|
+
* Generated at: 2026-04-24T17:30:19.705Z
|
|
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-04-
|
|
6
|
+
* Generated at: 2026-04-24T17:30:19.705Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.probableApiSpec = {
|
|
@@ -148,7 +148,7 @@ class SmarketsExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
148
148
|
}
|
|
149
149
|
async fetchEventsImpl(params) {
|
|
150
150
|
const rawEvents = await this.fetcher.fetchRawEvents(params);
|
|
151
|
-
const limit = params?.limit ||
|
|
151
|
+
const limit = params?.limit || 250000;
|
|
152
152
|
const query = (params?.query || '').toLowerCase();
|
|
153
153
|
const filtered = query
|
|
154
154
|
? rawEvents.filter((event) => (event.event.name || '').toLowerCase().includes(query))
|
package/dist/server/openapi.yaml
CHANGED
|
@@ -214,6 +214,45 @@ paths:
|
|
|
214
214
|
previous call slice directly from the cached snapshot — no additional API calls are made. The snapshot is
|
|
215
215
|
invalidated after `snapshotTTL` ms (configured via `ExchangeOptions` in the constructor). A request using a
|
|
216
216
|
cursor from an expired snapshot throws `'Cursor has expired'`.
|
|
217
|
+
'/api/{exchange}/fetchEventsPaginated':
|
|
218
|
+
get:
|
|
219
|
+
summary: Fetch Events Paginated
|
|
220
|
+
operationId: fetchEventsPaginated
|
|
221
|
+
parameters:
|
|
222
|
+
- $ref: '#/components/parameters/ExchangeParam'
|
|
223
|
+
- in: query
|
|
224
|
+
name: limit
|
|
225
|
+
required: false
|
|
226
|
+
schema:
|
|
227
|
+
type: number
|
|
228
|
+
- in: query
|
|
229
|
+
name: cursor
|
|
230
|
+
required: false
|
|
231
|
+
schema:
|
|
232
|
+
type: string
|
|
233
|
+
- in: query
|
|
234
|
+
name: filter
|
|
235
|
+
required: false
|
|
236
|
+
schema:
|
|
237
|
+
$ref: '#/components/schemas/EventFilterCriteria'
|
|
238
|
+
responses:
|
|
239
|
+
'200':
|
|
240
|
+
description: Fetch Events Paginated response
|
|
241
|
+
content:
|
|
242
|
+
application/json:
|
|
243
|
+
schema:
|
|
244
|
+
allOf:
|
|
245
|
+
- $ref: '#/components/schemas/BaseResponse'
|
|
246
|
+
- type: object
|
|
247
|
+
properties:
|
|
248
|
+
data:
|
|
249
|
+
$ref: '#/components/schemas/PaginatedEventsResult'
|
|
250
|
+
description: >-
|
|
251
|
+
Paginated variant of {@link fetchEvents}. On the first call (no `cursor`), all events are fetched from the
|
|
252
|
+
exchange and cached in an in-memory snapshot. A cursor is returned along with the first page. Subsequent calls
|
|
253
|
+
with that cursor serve additional pages directly from the cached snapshot -- no additional API calls are made.
|
|
254
|
+
The snapshot is invalidated after `snapshotTTL` ms (configured via `ExchangeOptions` in the constructor). A
|
|
255
|
+
request using a cursor from an expired snapshot throws `'Cursor has expired'`.
|
|
217
256
|
'/api/{exchange}/fetchEvents':
|
|
218
257
|
get:
|
|
219
258
|
summary: Fetch Events
|
|
@@ -2323,6 +2362,24 @@ components:
|
|
|
2323
2362
|
required:
|
|
2324
2363
|
- data
|
|
2325
2364
|
- total
|
|
2365
|
+
PaginatedEventsResult:
|
|
2366
|
+
type: object
|
|
2367
|
+
description: Shape returned by fetchEventsPaginated
|
|
2368
|
+
properties:
|
|
2369
|
+
data:
|
|
2370
|
+
type: array
|
|
2371
|
+
items:
|
|
2372
|
+
$ref: '#/components/schemas/UnifiedEvent'
|
|
2373
|
+
description: The page of unified events
|
|
2374
|
+
total:
|
|
2375
|
+
type: number
|
|
2376
|
+
description: Total number of events in the snapshot
|
|
2377
|
+
nextCursor:
|
|
2378
|
+
type: string
|
|
2379
|
+
description: 'Cursor to pass to the next call, or undefined if this is the last page'
|
|
2380
|
+
required:
|
|
2381
|
+
- data
|
|
2382
|
+
- total
|
|
2326
2383
|
MarketFilterParams:
|
|
2327
2384
|
type: object
|
|
2328
2385
|
properties:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxt-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.35.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.
|
|
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.
|
|
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.35.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.35.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",
|