pmxt-core 2.40.6 → 2.41.1
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/API_REFERENCE.md +1 -1
- package/dist/exchanges/baozi/websocket.js +7 -2
- package/dist/exchanges/kalshi/api.d.ts +1 -1
- package/dist/exchanges/kalshi/api.js +1 -1
- package/dist/exchanges/limitless/api.d.ts +1 -1
- package/dist/exchanges/limitless/api.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/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/utils.js +9 -19
- package/dist/exchanges/probable/api.d.ts +1 -1
- package/dist/exchanges/probable/api.js +1 -1
- package/dist/router/Router.js +4 -1
- package/dist/server/app.js +4 -8
- package/dist/server/method-verbs.json +6 -6
- package/dist/server/openapi.yaml +233 -69
- package/dist/server/utils/lock-file.js +4 -2
- package/dist/server/utils/port-manager.js +2 -2
- package/package.json +3 -3
package/API_REFERENCE.md
CHANGED
|
@@ -314,7 +314,7 @@ Both Polymarket and Kalshi support authenticated trading operations. You must pr
|
|
|
314
314
|
|
|
315
315
|
### Polymarket Authentication
|
|
316
316
|
|
|
317
|
-
Requires your **Polygon Private Key**. See [Setup Guide](https://github.com/
|
|
317
|
+
Requires your **Polygon Private Key**. See [Setup Guide](https://github.com/pmxt-dev/pmxt/blob/main/docs/SETUP_POLYMARKET.md) for details.
|
|
318
318
|
|
|
319
319
|
```typescript
|
|
320
320
|
import pmxt from 'pmxtjs';
|
|
@@ -44,8 +44,13 @@ class BaoziWebSocket {
|
|
|
44
44
|
};
|
|
45
45
|
this.resolveOrderBook(marketPubkey, orderBook);
|
|
46
46
|
}
|
|
47
|
-
catch {
|
|
48
|
-
//
|
|
47
|
+
catch (error) {
|
|
48
|
+
// Reject pending resolvers so callers fail fast
|
|
49
|
+
const rejecters = this.orderBookResolvers.get(marketPubkey) || [];
|
|
50
|
+
this.orderBookResolvers.set(marketPubkey, []);
|
|
51
|
+
for (const r of rejecters) {
|
|
52
|
+
r.reject(error instanceof Error ? error : new Error(String(error)));
|
|
53
|
+
}
|
|
49
54
|
}
|
|
50
55
|
}, 'confirmed');
|
|
51
56
|
this.subscriptions.set(marketPubkey, subId);
|
|
@@ -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-
|
|
3
|
+
* Generated at: 2026-05-15T18:19:35.222Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-15T18:19:35.222Z
|
|
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-
|
|
3
|
+
* Generated at: 2026-05-15T18:19:35.272Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-15T18:19:35.272Z
|
|
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-05-
|
|
3
|
+
* Generated at: 2026-05-15T18:19:35.290Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-15T18:19:35.290Z
|
|
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-
|
|
3
|
+
* Generated at: 2026-05-15T18:19:35.296Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-15T18:19:35.296Z
|
|
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-
|
|
3
|
+
* Generated at: 2026-05-15T18:19:35.230Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-15T18:19:35.230Z
|
|
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-
|
|
3
|
+
* Generated at: 2026-05-15T18:19:35.251Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-15T18:19:35.251Z
|
|
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-
|
|
3
|
+
* Generated at: 2026-05-15T18:19:35.248Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-15T18:19:35.248Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketGammaSpec = {
|
|
@@ -30,7 +30,7 @@ function mapMarketToUnified(event, market, options = {}) {
|
|
|
30
30
|
clobTokenIds = typeof market.clobTokenIds === 'string' ? JSON.parse(market.clobTokenIds) : (market.clobTokenIds || []);
|
|
31
31
|
}
|
|
32
32
|
catch (e) {
|
|
33
|
-
|
|
33
|
+
console.warn(`Error parsing clobTokenIds for market ${market.id}:`, e);
|
|
34
34
|
}
|
|
35
35
|
// Extract candidate/option name from market question for better outcome labels
|
|
36
36
|
let candidateName = null;
|
|
@@ -145,15 +145,10 @@ async function paginateParallel(url, params, http, maxResults = 10000) {
|
|
|
145
145
|
}
|
|
146
146
|
// 3. Fetch remaining pages in parallel
|
|
147
147
|
const remainingPages = await Promise.all(offsets.map(async (offset) => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return res.data || [];
|
|
153
|
-
}
|
|
154
|
-
catch (e) {
|
|
155
|
-
return []; // Swallow individual page errors to be robust
|
|
156
|
-
}
|
|
148
|
+
const res = await http.get(url, {
|
|
149
|
+
params: { ...params, limit: PAGE_SIZE, offset }
|
|
150
|
+
});
|
|
151
|
+
return res.data;
|
|
157
152
|
}));
|
|
158
153
|
return [firstPage, ...remainingPages].flat();
|
|
159
154
|
}
|
|
@@ -183,15 +178,10 @@ async function paginateSearchParallel(url, params, maxResults = 10000, http) {
|
|
|
183
178
|
pageNumbers.push(i);
|
|
184
179
|
}
|
|
185
180
|
const remainingPages = await Promise.all(pageNumbers.map(async (pageNum) => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return res.data?.events || [];
|
|
191
|
-
}
|
|
192
|
-
catch (e) {
|
|
193
|
-
return []; // Swallow individual page errors to be robust
|
|
194
|
-
}
|
|
181
|
+
const res = await http.get(url, {
|
|
182
|
+
params: { ...params, page: pageNum }
|
|
183
|
+
});
|
|
184
|
+
return res.data?.events;
|
|
195
185
|
}));
|
|
196
186
|
return [firstPageEvents, ...remainingPages].flat();
|
|
197
187
|
}
|
|
@@ -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-
|
|
3
|
+
* Generated at: 2026-05-15T18:19:35.279Z
|
|
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-
|
|
6
|
+
* Generated at: 2026-05-15T18:19:35.279Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.probableApiSpec = {
|
package/dist/router/Router.js
CHANGED
|
@@ -156,7 +156,10 @@ class Router extends BaseExchange_1.PredictionMarketExchange {
|
|
|
156
156
|
*/
|
|
157
157
|
async fetchMarketMatchesBrowse(params) {
|
|
158
158
|
const results = await this.client.browseMarketMatches(params);
|
|
159
|
-
|
|
159
|
+
if (!Array.isArray(results)) {
|
|
160
|
+
throw new Error(`browseMarketMatches returned unexpected type '${typeof results}'`);
|
|
161
|
+
}
|
|
162
|
+
return results;
|
|
160
163
|
}
|
|
161
164
|
/** @deprecated Use {@link fetchMarketMatches} instead. */
|
|
162
165
|
async fetchMatches(params) {
|
package/dist/server/app.js
CHANGED
|
@@ -20,14 +20,10 @@ function loadMethodVerbs() {
|
|
|
20
20
|
path_1.default.join(__dirname, "../../src/server/method-verbs.json"),
|
|
21
21
|
];
|
|
22
22
|
for (const file of candidates) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
// Fall through to the next candidate.
|
|
30
|
-
}
|
|
23
|
+
if (!fs_1.default.existsSync(file))
|
|
24
|
+
continue;
|
|
25
|
+
const raw = fs_1.default.readFileSync(file, "utf8");
|
|
26
|
+
return JSON.parse(raw);
|
|
31
27
|
}
|
|
32
28
|
console.warn("[pmxt-core] method-verbs.json not found — GET /api/:exchange/:method disabled. " +
|
|
33
29
|
"POST continues to work. Rebuild pmxt-core to regenerate.");
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
]
|
|
296
296
|
},
|
|
297
297
|
"watchOrderBook": {
|
|
298
|
-
"verb": "
|
|
298
|
+
"verb": "ws",
|
|
299
299
|
"args": [
|
|
300
300
|
{
|
|
301
301
|
"name": "outcomeId",
|
|
@@ -310,7 +310,7 @@
|
|
|
310
310
|
]
|
|
311
311
|
},
|
|
312
312
|
"watchOrderBooks": {
|
|
313
|
-
"verb": "
|
|
313
|
+
"verb": "ws",
|
|
314
314
|
"args": [
|
|
315
315
|
{
|
|
316
316
|
"name": "outcomeIds",
|
|
@@ -325,7 +325,7 @@
|
|
|
325
325
|
]
|
|
326
326
|
},
|
|
327
327
|
"unwatchOrderBook": {
|
|
328
|
-
"verb": "
|
|
328
|
+
"verb": "ws",
|
|
329
329
|
"args": [
|
|
330
330
|
{
|
|
331
331
|
"name": "outcomeId",
|
|
@@ -335,7 +335,7 @@
|
|
|
335
335
|
]
|
|
336
336
|
},
|
|
337
337
|
"watchTrades": {
|
|
338
|
-
"verb": "
|
|
338
|
+
"verb": "ws",
|
|
339
339
|
"args": [
|
|
340
340
|
{
|
|
341
341
|
"name": "outcomeId",
|
|
@@ -360,7 +360,7 @@
|
|
|
360
360
|
]
|
|
361
361
|
},
|
|
362
362
|
"watchAddress": {
|
|
363
|
-
"verb": "
|
|
363
|
+
"verb": "ws",
|
|
364
364
|
"args": [
|
|
365
365
|
{
|
|
366
366
|
"name": "address",
|
|
@@ -375,7 +375,7 @@
|
|
|
375
375
|
]
|
|
376
376
|
},
|
|
377
377
|
"unwatchAddress": {
|
|
378
|
-
"verb": "
|
|
378
|
+
"verb": "ws",
|
|
379
379
|
"args": [
|
|
380
380
|
{
|
|
381
381
|
"name": "address",
|
package/dist/server/openapi.yaml
CHANGED
|
@@ -1296,10 +1296,52 @@ paths:
|
|
|
1296
1296
|
function.
|
|
1297
1297
|
'/api/{exchange}/watchOrderBook':
|
|
1298
1298
|
post:
|
|
1299
|
-
summary: Watch Order Book
|
|
1299
|
+
summary: Watch Order Book (WebSocket)
|
|
1300
1300
|
operationId: watchOrderBook
|
|
1301
1301
|
parameters:
|
|
1302
1302
|
- $ref: '#/components/parameters/ExchangeParam'
|
|
1303
|
+
description: >-
|
|
1304
|
+
Watch order book updates in real-time via WebSocket. Returns a promise that resolves with the next order book
|
|
1305
|
+
update. Call repeatedly in a loop to stream updates (CCXT Pro pattern).
|
|
1306
|
+
|
|
1307
|
+
|
|
1308
|
+
**Transport:** WebSocket
|
|
1309
|
+
|
|
1310
|
+
|
|
1311
|
+
| Environment | URL |
|
|
1312
|
+
|
|
1313
|
+
|---|---|
|
|
1314
|
+
|
|
1315
|
+
| Local sidecar | `ws://localhost:3847/ws` |
|
|
1316
|
+
|
|
1317
|
+
| Hosted API | `wss://api.pmxt.dev/ws?apiKey=YOUR_KEY` |
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
**Subscribe:**
|
|
1321
|
+
|
|
1322
|
+
```json
|
|
1323
|
+
|
|
1324
|
+
{ "id": "req-1", "action": "subscribe", "method": "watchOrderBook", "args": [...] }
|
|
1325
|
+
|
|
1326
|
+
```
|
|
1327
|
+
|
|
1328
|
+
|
|
1329
|
+
**Server response:**
|
|
1330
|
+
|
|
1331
|
+
```json
|
|
1332
|
+
|
|
1333
|
+
{ "event": "data", "id": "req-1", "method": "watchOrderBook", "symbol": "...", "data": { ... } }
|
|
1334
|
+
|
|
1335
|
+
```
|
|
1336
|
+
|
|
1337
|
+
|
|
1338
|
+
**Unsubscribe:**
|
|
1339
|
+
|
|
1340
|
+
```json
|
|
1341
|
+
|
|
1342
|
+
{ "id": "req-1", "action": "unsubscribe" }
|
|
1343
|
+
|
|
1344
|
+
```
|
|
1303
1345
|
requestBody:
|
|
1304
1346
|
content:
|
|
1305
1347
|
application/json:
|
|
@@ -1309,19 +1351,13 @@ paths:
|
|
|
1309
1351
|
properties:
|
|
1310
1352
|
args:
|
|
1311
1353
|
type: array
|
|
1312
|
-
minItems: 1
|
|
1313
|
-
maxItems: 2
|
|
1314
1354
|
items:
|
|
1315
|
-
|
|
1316
|
-
- type: string
|
|
1317
|
-
- type: number
|
|
1355
|
+
type: string
|
|
1318
1356
|
credentials:
|
|
1319
1357
|
$ref: '#/components/schemas/ExchangeCredentials'
|
|
1320
|
-
required:
|
|
1321
|
-
- args
|
|
1322
1358
|
responses:
|
|
1323
1359
|
'200':
|
|
1324
|
-
description: Watch Order Book response
|
|
1360
|
+
description: Watch Order Book response (WebSocket data event)
|
|
1325
1361
|
content:
|
|
1326
1362
|
application/json:
|
|
1327
1363
|
schema:
|
|
@@ -1331,15 +1367,55 @@ paths:
|
|
|
1331
1367
|
properties:
|
|
1332
1368
|
data:
|
|
1333
1369
|
$ref: '#/components/schemas/OrderBook'
|
|
1334
|
-
description: >-
|
|
1335
|
-
Watch order book updates in real-time via WebSocket. Returns a promise that resolves with the next order book
|
|
1336
|
-
update. Call repeatedly in a loop to stream updates (CCXT Pro pattern).
|
|
1337
1370
|
'/api/{exchange}/watchOrderBooks':
|
|
1338
1371
|
post:
|
|
1339
|
-
summary: Watch Order Books
|
|
1372
|
+
summary: Watch Order Books (WebSocket)
|
|
1340
1373
|
operationId: watchOrderBooks
|
|
1341
1374
|
parameters:
|
|
1342
1375
|
- $ref: '#/components/parameters/ExchangeParam'
|
|
1376
|
+
description: >-
|
|
1377
|
+
Watch multiple order books simultaneously via WebSocket. Returns a promise that resolves with a record of order
|
|
1378
|
+
book snapshots keyed by ID. Exchanges with native batch support (e.g. Kalshi) send a single subscribe message
|
|
1379
|
+
for all tickers; others fall back to individual watchOrderBook calls.
|
|
1380
|
+
|
|
1381
|
+
|
|
1382
|
+
**Transport:** WebSocket
|
|
1383
|
+
|
|
1384
|
+
|
|
1385
|
+
| Environment | URL |
|
|
1386
|
+
|
|
1387
|
+
|---|---|
|
|
1388
|
+
|
|
1389
|
+
| Local sidecar | `ws://localhost:3847/ws` |
|
|
1390
|
+
|
|
1391
|
+
| Hosted API | `wss://api.pmxt.dev/ws?apiKey=YOUR_KEY` |
|
|
1392
|
+
|
|
1393
|
+
|
|
1394
|
+
**Subscribe:**
|
|
1395
|
+
|
|
1396
|
+
```json
|
|
1397
|
+
|
|
1398
|
+
{ "id": "req-1", "action": "subscribe", "method": "watchOrderBooks", "args": [...] }
|
|
1399
|
+
|
|
1400
|
+
```
|
|
1401
|
+
|
|
1402
|
+
|
|
1403
|
+
**Server response:**
|
|
1404
|
+
|
|
1405
|
+
```json
|
|
1406
|
+
|
|
1407
|
+
{ "event": "data", "id": "req-1", "method": "watchOrderBooks", "symbol": "...", "data": { ... } }
|
|
1408
|
+
|
|
1409
|
+
```
|
|
1410
|
+
|
|
1411
|
+
|
|
1412
|
+
**Unsubscribe:**
|
|
1413
|
+
|
|
1414
|
+
```json
|
|
1415
|
+
|
|
1416
|
+
{ "id": "req-1", "action": "unsubscribe" }
|
|
1417
|
+
|
|
1418
|
+
```
|
|
1343
1419
|
requestBody:
|
|
1344
1420
|
content:
|
|
1345
1421
|
application/json:
|
|
@@ -1349,21 +1425,13 @@ paths:
|
|
|
1349
1425
|
properties:
|
|
1350
1426
|
args:
|
|
1351
1427
|
type: array
|
|
1352
|
-
minItems: 1
|
|
1353
|
-
maxItems: 2
|
|
1354
1428
|
items:
|
|
1355
|
-
|
|
1356
|
-
- type: array
|
|
1357
|
-
items:
|
|
1358
|
-
type: string
|
|
1359
|
-
- type: number
|
|
1429
|
+
type: string
|
|
1360
1430
|
credentials:
|
|
1361
1431
|
$ref: '#/components/schemas/ExchangeCredentials'
|
|
1362
|
-
required:
|
|
1363
|
-
- args
|
|
1364
1432
|
responses:
|
|
1365
1433
|
'200':
|
|
1366
|
-
description: Watch Order Books response
|
|
1434
|
+
description: Watch Order Books response (WebSocket data event)
|
|
1367
1435
|
content:
|
|
1368
1436
|
application/json:
|
|
1369
1437
|
schema:
|
|
@@ -1375,16 +1443,36 @@ paths:
|
|
|
1375
1443
|
type: object
|
|
1376
1444
|
additionalProperties:
|
|
1377
1445
|
$ref: '#/components/schemas/OrderBook'
|
|
1378
|
-
description: >-
|
|
1379
|
-
Watch multiple order books simultaneously via WebSocket. Returns a promise that resolves with a record of order
|
|
1380
|
-
book snapshots keyed by ID. Exchanges with native batch support (e.g. Kalshi) send a single subscribe message
|
|
1381
|
-
for all tickers; others fall back to individual watchOrderBook calls.
|
|
1382
1446
|
'/api/{exchange}/unwatchOrderBook':
|
|
1383
1447
|
post:
|
|
1384
|
-
summary: Unwatch Order Book
|
|
1448
|
+
summary: Unwatch Order Book (WebSocket)
|
|
1385
1449
|
operationId: unwatchOrderBook
|
|
1386
1450
|
parameters:
|
|
1387
1451
|
- $ref: '#/components/parameters/ExchangeParam'
|
|
1452
|
+
description: |-
|
|
1453
|
+
Unsubscribe from a previously watched order book stream.
|
|
1454
|
+
|
|
1455
|
+
**Transport:** WebSocket
|
|
1456
|
+
|
|
1457
|
+
| Environment | URL |
|
|
1458
|
+
|---|---|
|
|
1459
|
+
| Local sidecar | `ws://localhost:3847/ws` |
|
|
1460
|
+
| Hosted API | `wss://api.pmxt.dev/ws?apiKey=YOUR_KEY` |
|
|
1461
|
+
|
|
1462
|
+
**Subscribe:**
|
|
1463
|
+
```json
|
|
1464
|
+
{ "id": "req-1", "action": "subscribe", "method": "unwatchOrderBook", "args": [...] }
|
|
1465
|
+
```
|
|
1466
|
+
|
|
1467
|
+
**Server response:**
|
|
1468
|
+
```json
|
|
1469
|
+
{ "event": "data", "id": "req-1", "method": "unwatchOrderBook", "symbol": "...", "data": { ... } }
|
|
1470
|
+
```
|
|
1471
|
+
|
|
1472
|
+
**Unsubscribe:**
|
|
1473
|
+
```json
|
|
1474
|
+
{ "id": "req-1", "action": "unsubscribe" }
|
|
1475
|
+
```
|
|
1388
1476
|
requestBody:
|
|
1389
1477
|
content:
|
|
1390
1478
|
application/json:
|
|
@@ -1394,28 +1482,65 @@ paths:
|
|
|
1394
1482
|
properties:
|
|
1395
1483
|
args:
|
|
1396
1484
|
type: array
|
|
1397
|
-
maxItems: 1
|
|
1398
1485
|
items:
|
|
1399
1486
|
type: string
|
|
1400
|
-
minItems: 1
|
|
1401
1487
|
credentials:
|
|
1402
1488
|
$ref: '#/components/schemas/ExchangeCredentials'
|
|
1403
|
-
required:
|
|
1404
|
-
- args
|
|
1405
1489
|
responses:
|
|
1406
1490
|
'200':
|
|
1407
|
-
description: Unwatch Order Book response
|
|
1491
|
+
description: Unwatch Order Book response (WebSocket data event)
|
|
1408
1492
|
content:
|
|
1409
1493
|
application/json:
|
|
1410
1494
|
schema:
|
|
1411
1495
|
$ref: '#/components/schemas/BaseResponse'
|
|
1412
|
-
description: Unsubscribe from a previously watched order book stream.
|
|
1413
1496
|
'/api/{exchange}/watchTrades':
|
|
1414
1497
|
post:
|
|
1415
|
-
summary: Watch Trades
|
|
1498
|
+
summary: Watch Trades (WebSocket)
|
|
1416
1499
|
operationId: watchTrades
|
|
1417
1500
|
parameters:
|
|
1418
1501
|
- $ref: '#/components/parameters/ExchangeParam'
|
|
1502
|
+
description: >-
|
|
1503
|
+
Watch trade executions in real-time via WebSocket. Returns a promise that resolves with the next trade(s). Call
|
|
1504
|
+
repeatedly in a loop to stream updates (CCXT Pro pattern).
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
**Transport:** WebSocket
|
|
1508
|
+
|
|
1509
|
+
|
|
1510
|
+
| Environment | URL |
|
|
1511
|
+
|
|
1512
|
+
|---|---|
|
|
1513
|
+
|
|
1514
|
+
| Local sidecar | `ws://localhost:3847/ws` |
|
|
1515
|
+
|
|
1516
|
+
| Hosted API | `wss://api.pmxt.dev/ws?apiKey=YOUR_KEY` |
|
|
1517
|
+
|
|
1518
|
+
|
|
1519
|
+
**Subscribe:**
|
|
1520
|
+
|
|
1521
|
+
```json
|
|
1522
|
+
|
|
1523
|
+
{ "id": "req-1", "action": "subscribe", "method": "watchTrades", "args": [...] }
|
|
1524
|
+
|
|
1525
|
+
```
|
|
1526
|
+
|
|
1527
|
+
|
|
1528
|
+
**Server response:**
|
|
1529
|
+
|
|
1530
|
+
```json
|
|
1531
|
+
|
|
1532
|
+
{ "event": "data", "id": "req-1", "method": "watchTrades", "symbol": "...", "data": { ... } }
|
|
1533
|
+
|
|
1534
|
+
```
|
|
1535
|
+
|
|
1536
|
+
|
|
1537
|
+
**Unsubscribe:**
|
|
1538
|
+
|
|
1539
|
+
```json
|
|
1540
|
+
|
|
1541
|
+
{ "id": "req-1", "action": "unsubscribe" }
|
|
1542
|
+
|
|
1543
|
+
```
|
|
1419
1544
|
requestBody:
|
|
1420
1545
|
content:
|
|
1421
1546
|
application/json:
|
|
@@ -1425,21 +1550,13 @@ paths:
|
|
|
1425
1550
|
properties:
|
|
1426
1551
|
args:
|
|
1427
1552
|
type: array
|
|
1428
|
-
minItems: 1
|
|
1429
|
-
maxItems: 4
|
|
1430
1553
|
items:
|
|
1431
|
-
|
|
1432
|
-
- type: string
|
|
1433
|
-
- type: string
|
|
1434
|
-
- type: number
|
|
1435
|
-
- type: number
|
|
1554
|
+
type: string
|
|
1436
1555
|
credentials:
|
|
1437
1556
|
$ref: '#/components/schemas/ExchangeCredentials'
|
|
1438
|
-
required:
|
|
1439
|
-
- args
|
|
1440
1557
|
responses:
|
|
1441
1558
|
'200':
|
|
1442
|
-
description: Watch Trades response
|
|
1559
|
+
description: Watch Trades response (WebSocket data event)
|
|
1443
1560
|
content:
|
|
1444
1561
|
application/json:
|
|
1445
1562
|
schema:
|
|
@@ -1451,15 +1568,54 @@ paths:
|
|
|
1451
1568
|
type: array
|
|
1452
1569
|
items:
|
|
1453
1570
|
$ref: '#/components/schemas/Trade'
|
|
1454
|
-
description: >-
|
|
1455
|
-
Watch trade executions in real-time via WebSocket. Returns a promise that resolves with the next trade(s). Call
|
|
1456
|
-
repeatedly in a loop to stream updates (CCXT Pro pattern).
|
|
1457
1571
|
'/api/{exchange}/watchAddress':
|
|
1458
1572
|
post:
|
|
1459
|
-
summary: Watch Address
|
|
1573
|
+
summary: Watch Address (WebSocket)
|
|
1460
1574
|
operationId: watchAddress
|
|
1461
1575
|
parameters:
|
|
1462
1576
|
- $ref: '#/components/parameters/ExchangeParam'
|
|
1577
|
+
description: >-
|
|
1578
|
+
Stream activity for a public wallet address Returns a promise that resolves with the next activity snapshot
|
|
1579
|
+
whenever a change is detected. Call repeatedly in a loop to stream updates (CCXT Pro pattern).
|
|
1580
|
+
|
|
1581
|
+
|
|
1582
|
+
**Transport:** WebSocket
|
|
1583
|
+
|
|
1584
|
+
|
|
1585
|
+
| Environment | URL |
|
|
1586
|
+
|
|
1587
|
+
|---|---|
|
|
1588
|
+
|
|
1589
|
+
| Local sidecar | `ws://localhost:3847/ws` |
|
|
1590
|
+
|
|
1591
|
+
| Hosted API | `wss://api.pmxt.dev/ws?apiKey=YOUR_KEY` |
|
|
1592
|
+
|
|
1593
|
+
|
|
1594
|
+
**Subscribe:**
|
|
1595
|
+
|
|
1596
|
+
```json
|
|
1597
|
+
|
|
1598
|
+
{ "id": "req-1", "action": "subscribe", "method": "watchAddress", "args": [...] }
|
|
1599
|
+
|
|
1600
|
+
```
|
|
1601
|
+
|
|
1602
|
+
|
|
1603
|
+
**Server response:**
|
|
1604
|
+
|
|
1605
|
+
```json
|
|
1606
|
+
|
|
1607
|
+
{ "event": "data", "id": "req-1", "method": "watchAddress", "symbol": "...", "data": { ... } }
|
|
1608
|
+
|
|
1609
|
+
```
|
|
1610
|
+
|
|
1611
|
+
|
|
1612
|
+
**Unsubscribe:**
|
|
1613
|
+
|
|
1614
|
+
```json
|
|
1615
|
+
|
|
1616
|
+
{ "id": "req-1", "action": "unsubscribe" }
|
|
1617
|
+
|
|
1618
|
+
```
|
|
1463
1619
|
requestBody:
|
|
1464
1620
|
content:
|
|
1465
1621
|
application/json:
|
|
@@ -1469,21 +1625,13 @@ paths:
|
|
|
1469
1625
|
properties:
|
|
1470
1626
|
args:
|
|
1471
1627
|
type: array
|
|
1472
|
-
minItems: 1
|
|
1473
|
-
maxItems: 2
|
|
1474
1628
|
items:
|
|
1475
|
-
|
|
1476
|
-
- type: string
|
|
1477
|
-
- type: array
|
|
1478
|
-
items:
|
|
1479
|
-
type: object
|
|
1629
|
+
type: string
|
|
1480
1630
|
credentials:
|
|
1481
1631
|
$ref: '#/components/schemas/ExchangeCredentials'
|
|
1482
|
-
required:
|
|
1483
|
-
- args
|
|
1484
1632
|
responses:
|
|
1485
1633
|
'200':
|
|
1486
|
-
description: Watch Address response
|
|
1634
|
+
description: Watch Address response (WebSocket data event)
|
|
1487
1635
|
content:
|
|
1488
1636
|
application/json:
|
|
1489
1637
|
schema:
|
|
@@ -1493,15 +1641,36 @@ paths:
|
|
|
1493
1641
|
properties:
|
|
1494
1642
|
data:
|
|
1495
1643
|
type: object
|
|
1496
|
-
description: >-
|
|
1497
|
-
Stream activity for a public wallet address Returns a promise that resolves with the next activity snapshot
|
|
1498
|
-
whenever a change is detected. Call repeatedly in a loop to stream updates (CCXT Pro pattern).
|
|
1499
1644
|
'/api/{exchange}/unwatchAddress':
|
|
1500
1645
|
post:
|
|
1501
|
-
summary: Unwatch Address
|
|
1646
|
+
summary: Unwatch Address (WebSocket)
|
|
1502
1647
|
operationId: unwatchAddress
|
|
1503
1648
|
parameters:
|
|
1504
1649
|
- $ref: '#/components/parameters/ExchangeParam'
|
|
1650
|
+
description: |-
|
|
1651
|
+
Stop watching a previously registered wallet address and release its resource updates.
|
|
1652
|
+
|
|
1653
|
+
**Transport:** WebSocket
|
|
1654
|
+
|
|
1655
|
+
| Environment | URL |
|
|
1656
|
+
|---|---|
|
|
1657
|
+
| Local sidecar | `ws://localhost:3847/ws` |
|
|
1658
|
+
| Hosted API | `wss://api.pmxt.dev/ws?apiKey=YOUR_KEY` |
|
|
1659
|
+
|
|
1660
|
+
**Subscribe:**
|
|
1661
|
+
```json
|
|
1662
|
+
{ "id": "req-1", "action": "subscribe", "method": "unwatchAddress", "args": [...] }
|
|
1663
|
+
```
|
|
1664
|
+
|
|
1665
|
+
**Server response:**
|
|
1666
|
+
```json
|
|
1667
|
+
{ "event": "data", "id": "req-1", "method": "unwatchAddress", "symbol": "...", "data": { ... } }
|
|
1668
|
+
```
|
|
1669
|
+
|
|
1670
|
+
**Unsubscribe:**
|
|
1671
|
+
```json
|
|
1672
|
+
{ "id": "req-1", "action": "unsubscribe" }
|
|
1673
|
+
```
|
|
1505
1674
|
requestBody:
|
|
1506
1675
|
content:
|
|
1507
1676
|
application/json:
|
|
@@ -1511,22 +1680,17 @@ paths:
|
|
|
1511
1680
|
properties:
|
|
1512
1681
|
args:
|
|
1513
1682
|
type: array
|
|
1514
|
-
maxItems: 1
|
|
1515
1683
|
items:
|
|
1516
1684
|
type: string
|
|
1517
|
-
minItems: 1
|
|
1518
1685
|
credentials:
|
|
1519
1686
|
$ref: '#/components/schemas/ExchangeCredentials'
|
|
1520
|
-
required:
|
|
1521
|
-
- args
|
|
1522
1687
|
responses:
|
|
1523
1688
|
'200':
|
|
1524
|
-
description: Unwatch Address response
|
|
1689
|
+
description: Unwatch Address response (WebSocket data event)
|
|
1525
1690
|
content:
|
|
1526
1691
|
application/json:
|
|
1527
1692
|
schema:
|
|
1528
1693
|
$ref: '#/components/schemas/BaseResponse'
|
|
1529
|
-
description: Stop watching a previously registered wallet address and release its resource updates.
|
|
1530
1694
|
'/api/{exchange}/testDummyMethod':
|
|
1531
1695
|
post:
|
|
1532
1696
|
summary: Test Dummy Method
|
|
@@ -47,14 +47,14 @@ class PortManager {
|
|
|
47
47
|
throw new Error(`No available ports found in range ${startPort}-${startPort + 100}`);
|
|
48
48
|
}
|
|
49
49
|
isPortAvailable(port) {
|
|
50
|
-
return new Promise((resolve) => {
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
51
|
const server = net.createServer();
|
|
52
52
|
server.once('error', (err) => {
|
|
53
53
|
if (err.code === 'EADDRINUSE') {
|
|
54
54
|
resolve(false);
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
|
-
|
|
57
|
+
reject(err);
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
server.once('listening', () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxt-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.41.1",
|
|
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.41.1,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.41.1,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",
|