pmxtjs 2.9.1 → 2.10.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/esm/pmxt/client.d.ts +16 -0
- package/dist/esm/pmxt/client.js +43 -0
- package/dist/pmxt/client.d.ts +16 -0
- package/dist/pmxt/client.js +43 -0
- package/generated/package.json +1 -1
- package/package.json +2 -2
- package/pmxt/client.ts +50 -2
|
@@ -44,6 +44,22 @@ export declare abstract class Exchange {
|
|
|
44
44
|
private initializeServer;
|
|
45
45
|
protected handleResponse(response: any): any;
|
|
46
46
|
protected getCredentials(): ExchangeCredentials | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Call an exchange-specific REST endpoint by its operationId.
|
|
49
|
+
* This provides direct access to all implicit API methods defined in
|
|
50
|
+
* the exchange's OpenAPI spec (e.g., Polymarket CLOB, Kalshi trading API).
|
|
51
|
+
*
|
|
52
|
+
* @param operationId - The operationId (or auto-generated name) of the endpoint
|
|
53
|
+
* @param params - Optional parameters to pass to the endpoint
|
|
54
|
+
* @returns The raw response data from the exchange
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* // Call a Polymarket CLOB endpoint directly
|
|
59
|
+
* const result = await poly.callApi('getMarket', { condition_id: '0x...' });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
callApi(operationId: string, params?: Record<string, any>): Promise<any>;
|
|
47
63
|
/**
|
|
48
64
|
* Get active markets from the exchange.
|
|
49
65
|
*
|
package/dist/esm/pmxt/client.js
CHANGED
|
@@ -206,6 +206,49 @@ export class Exchange {
|
|
|
206
206
|
signatureType: this.signatureType,
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
|
+
// Low-Level API Access
|
|
210
|
+
/**
|
|
211
|
+
* Call an exchange-specific REST endpoint by its operationId.
|
|
212
|
+
* This provides direct access to all implicit API methods defined in
|
|
213
|
+
* the exchange's OpenAPI spec (e.g., Polymarket CLOB, Kalshi trading API).
|
|
214
|
+
*
|
|
215
|
+
* @param operationId - The operationId (or auto-generated name) of the endpoint
|
|
216
|
+
* @param params - Optional parameters to pass to the endpoint
|
|
217
|
+
* @returns The raw response data from the exchange
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* // Call a Polymarket CLOB endpoint directly
|
|
222
|
+
* const result = await poly.callApi('getMarket', { condition_id: '0x...' });
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
async callApi(operationId, params) {
|
|
226
|
+
await this.initPromise;
|
|
227
|
+
try {
|
|
228
|
+
const url = `${this.config.basePath}/api/${this.exchangeName}/callApi`;
|
|
229
|
+
const requestBody = {
|
|
230
|
+
args: [operationId, params],
|
|
231
|
+
credentials: this.getCredentials()
|
|
232
|
+
};
|
|
233
|
+
const response = await fetch(url, {
|
|
234
|
+
method: 'POST',
|
|
235
|
+
headers: {
|
|
236
|
+
'Content-Type': 'application/json',
|
|
237
|
+
...this.config.headers
|
|
238
|
+
},
|
|
239
|
+
body: JSON.stringify(requestBody)
|
|
240
|
+
});
|
|
241
|
+
if (!response.ok) {
|
|
242
|
+
const error = await response.json().catch(() => ({}));
|
|
243
|
+
throw new Error(error.error?.message || response.statusText);
|
|
244
|
+
}
|
|
245
|
+
const json = await response.json();
|
|
246
|
+
return this.handleResponse(json);
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
throw new Error(`Failed to call API '${operationId}': ${error}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
209
252
|
// Market Data Methods
|
|
210
253
|
/**
|
|
211
254
|
* Get active markets from the exchange.
|
package/dist/pmxt/client.d.ts
CHANGED
|
@@ -44,6 +44,22 @@ export declare abstract class Exchange {
|
|
|
44
44
|
private initializeServer;
|
|
45
45
|
protected handleResponse(response: any): any;
|
|
46
46
|
protected getCredentials(): ExchangeCredentials | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Call an exchange-specific REST endpoint by its operationId.
|
|
49
|
+
* This provides direct access to all implicit API methods defined in
|
|
50
|
+
* the exchange's OpenAPI spec (e.g., Polymarket CLOB, Kalshi trading API).
|
|
51
|
+
*
|
|
52
|
+
* @param operationId - The operationId (or auto-generated name) of the endpoint
|
|
53
|
+
* @param params - Optional parameters to pass to the endpoint
|
|
54
|
+
* @returns The raw response data from the exchange
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* // Call a Polymarket CLOB endpoint directly
|
|
59
|
+
* const result = await poly.callApi('getMarket', { condition_id: '0x...' });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
callApi(operationId: string, params?: Record<string, any>): Promise<any>;
|
|
47
63
|
/**
|
|
48
64
|
* Get active markets from the exchange.
|
|
49
65
|
*
|
package/dist/pmxt/client.js
CHANGED
|
@@ -209,6 +209,49 @@ class Exchange {
|
|
|
209
209
|
signatureType: this.signatureType,
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
|
+
// Low-Level API Access
|
|
213
|
+
/**
|
|
214
|
+
* Call an exchange-specific REST endpoint by its operationId.
|
|
215
|
+
* This provides direct access to all implicit API methods defined in
|
|
216
|
+
* the exchange's OpenAPI spec (e.g., Polymarket CLOB, Kalshi trading API).
|
|
217
|
+
*
|
|
218
|
+
* @param operationId - The operationId (or auto-generated name) of the endpoint
|
|
219
|
+
* @param params - Optional parameters to pass to the endpoint
|
|
220
|
+
* @returns The raw response data from the exchange
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* // Call a Polymarket CLOB endpoint directly
|
|
225
|
+
* const result = await poly.callApi('getMarket', { condition_id: '0x...' });
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
async callApi(operationId, params) {
|
|
229
|
+
await this.initPromise;
|
|
230
|
+
try {
|
|
231
|
+
const url = `${this.config.basePath}/api/${this.exchangeName}/callApi`;
|
|
232
|
+
const requestBody = {
|
|
233
|
+
args: [operationId, params],
|
|
234
|
+
credentials: this.getCredentials()
|
|
235
|
+
};
|
|
236
|
+
const response = await fetch(url, {
|
|
237
|
+
method: 'POST',
|
|
238
|
+
headers: {
|
|
239
|
+
'Content-Type': 'application/json',
|
|
240
|
+
...this.config.headers
|
|
241
|
+
},
|
|
242
|
+
body: JSON.stringify(requestBody)
|
|
243
|
+
});
|
|
244
|
+
if (!response.ok) {
|
|
245
|
+
const error = await response.json().catch(() => ({}));
|
|
246
|
+
throw new Error(error.error?.message || response.statusText);
|
|
247
|
+
}
|
|
248
|
+
const json = await response.json();
|
|
249
|
+
return this.handleResponse(json);
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
throw new Error(`Failed to call API '${operationId}': ${error}`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
212
255
|
// Market Data Methods
|
|
213
256
|
/**
|
|
214
257
|
* Get active markets from the exchange.
|
package/generated/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxtjs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "Unified prediction market data API - The ccxt for prediction markets",
|
|
5
5
|
"author": "PMXT Contributors",
|
|
6
6
|
"repository": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"unified"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"pmxt-core": "2.
|
|
45
|
+
"pmxt-core": "2.10.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/jest": "^30.0.0",
|
package/pmxt/client.ts
CHANGED
|
@@ -290,14 +290,62 @@ export abstract class Exchange {
|
|
|
290
290
|
};
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
+
// Low-Level API Access
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Call an exchange-specific REST endpoint by its operationId.
|
|
297
|
+
* This provides direct access to all implicit API methods defined in
|
|
298
|
+
* the exchange's OpenAPI spec (e.g., Polymarket CLOB, Kalshi trading API).
|
|
299
|
+
*
|
|
300
|
+
* @param operationId - The operationId (or auto-generated name) of the endpoint
|
|
301
|
+
* @param params - Optional parameters to pass to the endpoint
|
|
302
|
+
* @returns The raw response data from the exchange
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* ```typescript
|
|
306
|
+
* // Call a Polymarket CLOB endpoint directly
|
|
307
|
+
* const result = await poly.callApi('getMarket', { condition_id: '0x...' });
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
async callApi(operationId: string, params?: Record<string, any>): Promise<any> {
|
|
311
|
+
await this.initPromise;
|
|
312
|
+
try {
|
|
313
|
+
const url = `${this.config.basePath}/api/${this.exchangeName}/callApi`;
|
|
314
|
+
|
|
315
|
+
const requestBody: any = {
|
|
316
|
+
args: [operationId, params],
|
|
317
|
+
credentials: this.getCredentials()
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
const response = await fetch(url, {
|
|
321
|
+
method: 'POST',
|
|
322
|
+
headers: {
|
|
323
|
+
'Content-Type': 'application/json',
|
|
324
|
+
...this.config.headers
|
|
325
|
+
},
|
|
326
|
+
body: JSON.stringify(requestBody)
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
if (!response.ok) {
|
|
330
|
+
const error = await response.json().catch(() => ({}));
|
|
331
|
+
throw new Error(error.error?.message || response.statusText);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const json = await response.json();
|
|
335
|
+
return this.handleResponse(json);
|
|
336
|
+
} catch (error) {
|
|
337
|
+
throw new Error(`Failed to call API '${operationId}': ${error}`);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
293
341
|
// Market Data Methods
|
|
294
342
|
|
|
295
343
|
/**
|
|
296
344
|
* Get active markets from the exchange.
|
|
297
|
-
*
|
|
345
|
+
*
|
|
298
346
|
* @param params - Optional filter parameters
|
|
299
347
|
* @returns List of unified markets
|
|
300
|
-
*
|
|
348
|
+
*
|
|
301
349
|
* @example
|
|
302
350
|
* ```typescript
|
|
303
351
|
* const markets = await exchange.fetchMarkets({ limit: 20, sort: "volume" });
|