parsec-api 0.9.0 → 0.11.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/CHANGELOG.md +38 -0
- package/README.md +0 -117
- package/client.d.mts +18 -25
- package/client.d.mts.map +1 -1
- package/client.d.ts +18 -25
- package/client.d.ts.map +1 -1
- package/client.js +18 -38
- package/client.js.map +1 -1
- package/client.mjs +18 -38
- package/client.mjs.map +1 -1
- package/core/error.d.mts +0 -12
- package/core/error.d.mts.map +1 -1
- package/core/error.d.ts +0 -12
- package/core/error.d.ts.map +1 -1
- package/core/error.js +0 -24
- package/core/error.js.map +1 -1
- package/core/error.mjs +0 -24
- package/core/error.mjs.map +1 -1
- package/index.d.mts +0 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +0 -1
- package/index.d.ts.map +1 -1
- package/index.js +1 -3
- package/index.js.map +1 -1
- package/index.mjs +0 -1
- package/index.mjs.map +1 -1
- package/internal/tslib.js +21 -21
- package/internal/utils/query.d.mts +2 -0
- package/internal/utils/query.d.mts.map +1 -0
- package/internal/utils/query.d.ts +2 -0
- package/internal/utils/query.d.ts.map +1 -0
- package/internal/utils/query.js +10 -0
- package/internal/utils/query.js.map +1 -0
- package/internal/utils/query.mjs +6 -0
- package/internal/utils/query.mjs.map +1 -0
- package/internal/utils.d.mts +1 -0
- package/internal/utils.d.ts +1 -0
- package/internal/utils.js +1 -0
- package/internal/utils.js.map +1 -1
- package/internal/utils.mjs +1 -0
- package/package.json +2 -3
- package/resources/account.d.mts +63 -39
- package/resources/account.d.mts.map +1 -1
- package/resources/account.d.ts +63 -39
- package/resources/account.d.ts.map +1 -1
- package/resources/account.js +5 -13
- package/resources/account.js.map +1 -1
- package/resources/account.mjs +5 -13
- package/resources/account.mjs.map +1 -1
- package/resources/builder/builder.d.mts +40 -0
- package/resources/builder/builder.d.mts.map +1 -0
- package/resources/builder/builder.d.ts +40 -0
- package/resources/builder/builder.d.ts.map +1 -0
- package/resources/builder/builder.js +32 -0
- package/resources/builder/builder.js.map +1 -0
- package/resources/builder/builder.mjs +27 -0
- package/resources/builder/builder.mjs.map +1 -0
- package/resources/builder/escrow.d.mts +49 -0
- package/resources/builder/escrow.d.mts.map +1 -0
- package/resources/builder/escrow.d.ts +49 -0
- package/resources/builder/escrow.d.ts.map +1 -0
- package/resources/builder/escrow.js +17 -0
- package/resources/builder/escrow.js.map +1 -0
- package/resources/builder/escrow.mjs +13 -0
- package/resources/builder/escrow.mjs.map +1 -0
- package/resources/builder/index.d.mts +5 -0
- package/resources/builder/index.d.mts.map +1 -0
- package/resources/builder/index.d.ts +5 -0
- package/resources/builder/index.d.ts.map +1 -0
- package/resources/builder/index.js +13 -0
- package/resources/builder/index.js.map +1 -0
- package/resources/builder/index.mjs +6 -0
- package/resources/builder/index.mjs.map +1 -0
- package/resources/builder/onboard.d.mts +163 -0
- package/resources/builder/onboard.d.mts.map +1 -0
- package/resources/builder/onboard.d.ts +163 -0
- package/resources/builder/onboard.d.ts.map +1 -0
- package/resources/builder/onboard.js +16 -0
- package/resources/builder/onboard.js.map +1 -0
- package/resources/builder/onboard.mjs +12 -0
- package/resources/builder/onboard.mjs.map +1 -0
- package/resources/builder/users.d.mts +469 -0
- package/resources/builder/users.d.mts.map +1 -0
- package/resources/builder/users.d.ts +469 -0
- package/resources/builder/users.d.ts.map +1 -0
- package/resources/builder/users.js +46 -0
- package/resources/builder/users.js.map +1 -0
- package/resources/builder/users.mjs +42 -0
- package/resources/builder/users.mjs.map +1 -0
- package/resources/builder.d.mts +2 -0
- package/resources/builder.d.mts.map +1 -0
- package/resources/builder.d.ts +2 -0
- package/resources/builder.d.ts.map +1 -0
- package/resources/builder.js +6 -0
- package/resources/builder.js.map +1 -0
- package/resources/builder.mjs +3 -0
- package/resources/builder.mjs.map +1 -0
- package/resources/ctf.d.mts +97 -0
- package/resources/ctf.d.mts.map +1 -0
- package/resources/ctf.d.ts +97 -0
- package/resources/ctf.d.ts.map +1 -0
- package/resources/ctf.js +59 -0
- package/resources/ctf.js.map +1 -0
- package/resources/ctf.mjs +55 -0
- package/resources/ctf.mjs.map +1 -0
- package/resources/events.d.mts +84 -12
- package/resources/events.d.mts.map +1 -1
- package/resources/events.d.ts +84 -12
- package/resources/events.d.ts.map +1 -1
- package/resources/events.js +4 -15
- package/resources/events.js.map +1 -1
- package/resources/events.mjs +4 -15
- package/resources/events.mjs.map +1 -1
- package/resources/exchanges.d.mts +1 -1
- package/resources/exchanges.d.mts.map +1 -1
- package/resources/exchanges.d.ts +1 -1
- package/resources/exchanges.d.ts.map +1 -1
- package/resources/fills.d.mts +76 -0
- package/resources/fills.d.mts.map +1 -0
- package/resources/fills.d.ts +76 -0
- package/resources/fills.d.ts.map +1 -0
- package/resources/fills.js +27 -0
- package/resources/fills.js.map +1 -0
- package/resources/fills.mjs +23 -0
- package/resources/fills.mjs.map +1 -0
- package/resources/index.d.mts +7 -3
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +7 -3
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +11 -3
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +6 -2
- package/resources/index.mjs.map +1 -1
- package/resources/markets.d.mts +92 -19
- package/resources/markets.d.mts.map +1 -1
- package/resources/markets.d.ts +92 -19
- package/resources/markets.d.ts.map +1 -1
- package/resources/markets.js +1 -30
- package/resources/markets.js.map +1 -1
- package/resources/markets.mjs +1 -29
- package/resources/markets.mjs.map +1 -1
- package/resources/onboard.d.mts +91 -0
- package/resources/onboard.d.mts.map +1 -0
- package/resources/onboard.d.ts +91 -0
- package/resources/onboard.d.ts.map +1 -0
- package/resources/onboard.js +17 -0
- package/resources/onboard.js.map +1 -0
- package/resources/onboard.mjs +13 -0
- package/resources/onboard.mjs.map +1 -0
- package/resources/orderbook.d.mts +5 -11
- package/resources/orderbook.d.mts.map +1 -1
- package/resources/orderbook.d.ts +5 -11
- package/resources/orderbook.d.ts.map +1 -1
- package/resources/orderbook.js +2 -1
- package/resources/orderbook.js.map +1 -1
- package/resources/orderbook.mjs +2 -1
- package/resources/orderbook.mjs.map +1 -1
- package/resources/price.d.mts +1 -0
- package/resources/price.d.mts.map +1 -1
- package/resources/price.d.ts +1 -0
- package/resources/price.d.ts.map +1 -1
- package/resources/price.js +1 -0
- package/resources/price.js.map +1 -1
- package/resources/price.mjs +1 -0
- package/resources/price.mjs.map +1 -1
- package/resources/trades.d.mts +12 -2
- package/resources/trades.d.mts.map +1 -1
- package/resources/trades.d.ts +12 -2
- package/resources/trades.d.ts.map +1 -1
- package/resources/trades.js +2 -1
- package/resources/trades.js.map +1 -1
- package/resources/trades.mjs +2 -1
- package/resources/trades.mjs.map +1 -1
- package/resources/wallet.d.mts +177 -0
- package/resources/wallet.d.mts.map +1 -0
- package/resources/wallet.d.ts +177 -0
- package/resources/wallet.d.ts.map +1 -0
- package/resources/wallet.js +26 -0
- package/resources/wallet.js.map +1 -0
- package/resources/wallet.mjs +22 -0
- package/resources/wallet.mjs.map +1 -0
- package/src/client.ts +49 -63
- package/src/core/error.ts +0 -29
- package/src/index.ts +0 -14
- package/src/internal/utils/query.ts +7 -0
- package/src/internal/utils.ts +1 -0
- package/src/resources/account.ts +78 -55
- package/src/resources/builder/builder.ts +78 -0
- package/src/resources/builder/escrow.ts +62 -0
- package/src/resources/builder/index.ts +15 -0
- package/src/resources/builder/onboard.ts +206 -0
- package/src/resources/builder/users.ts +606 -0
- package/src/resources/builder.ts +3 -0
- package/src/resources/ctf.ts +122 -0
- package/src/resources/events.ts +104 -26
- package/src/resources/exchanges.ts +2 -2
- package/src/resources/fills.ts +107 -0
- package/src/resources/index.ts +12 -15
- package/src/resources/markets.ts +114 -49
- package/src/resources/onboard.ts +116 -0
- package/src/resources/orderbook.ts +4 -12
- package/src/resources/price.ts +1 -0
- package/src/resources/trades.ts +14 -3
- package/src/resources/wallet.ts +224 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
- package/resources/approvals.d.mts +0 -74
- package/resources/approvals.d.mts.map +0 -1
- package/resources/approvals.d.ts +0 -74
- package/resources/approvals.d.ts.map +0 -1
- package/resources/approvals.js +0 -22
- package/resources/approvals.js.map +0 -1
- package/resources/approvals.mjs +0 -18
- package/resources/approvals.mjs.map +0 -1
- package/src/resources/approvals.ts +0 -107
package/src/client.ts
CHANGED
|
@@ -11,31 +11,23 @@ import type { APIResponseProps } from './internal/parse';
|
|
|
11
11
|
import { getPlatformHeaders } from './internal/detect-platform';
|
|
12
12
|
import * as Shims from './internal/shims';
|
|
13
13
|
import * as Opts from './internal/request-options';
|
|
14
|
-
import
|
|
14
|
+
import { stringifyQuery } from './internal/utils/query';
|
|
15
15
|
import { VERSION } from './version';
|
|
16
16
|
import * as Errors from './core/error';
|
|
17
17
|
import * as Uploads from './core/uploads';
|
|
18
18
|
import * as API from './resources/index';
|
|
19
|
-
import { ParsecWebSocket, type ParsecWebSocketOptions } from './streaming';
|
|
20
19
|
import { APIPromise } from './core/api-promise';
|
|
21
20
|
import {
|
|
22
21
|
Account,
|
|
23
22
|
AccountBalanceParams,
|
|
24
23
|
AccountBalanceResponse,
|
|
25
|
-
AccountCapabilitiesResponse,
|
|
26
24
|
AccountPingParams,
|
|
27
25
|
AccountPingResponse,
|
|
28
|
-
|
|
26
|
+
AccountUsageResponse,
|
|
29
27
|
AccountUserActivityParams,
|
|
30
28
|
AccountUserActivityResponse,
|
|
31
29
|
} from './resources/account';
|
|
32
|
-
import {
|
|
33
|
-
ApprovalListParams,
|
|
34
|
-
ApprovalListResponse,
|
|
35
|
-
ApprovalSetParams,
|
|
36
|
-
ApprovalSetResponse,
|
|
37
|
-
Approvals,
|
|
38
|
-
} from './resources/approvals';
|
|
30
|
+
import { Ctf, CtfMergeParams, CtfRedeemParams, CtfResponse, CtfSplitParams } from './resources/ctf';
|
|
39
31
|
import { EventListParams, EventListResponse, Events } from './resources/events';
|
|
40
32
|
import { ExchangeListResponse, Exchanges } from './resources/exchanges';
|
|
41
33
|
import {
|
|
@@ -43,7 +35,9 @@ import {
|
|
|
43
35
|
ExecutionPriceRetrieveParams,
|
|
44
36
|
ExecutionPriceRetrieveResponse,
|
|
45
37
|
} from './resources/execution-price';
|
|
38
|
+
import { FillListParams, FillListResponse, Fills } from './resources/fills';
|
|
46
39
|
import { MarketListParams, MarketListResponse, Markets } from './resources/markets';
|
|
40
|
+
import { Onboard, OnboardCreateParams, OnboardCreateResponse } from './resources/onboard';
|
|
47
41
|
import { Orderbook, OrderbookRetrieveParams, OrderbookRetrieveResponse } from './resources/orderbook';
|
|
48
42
|
import {
|
|
49
43
|
Order,
|
|
@@ -57,12 +51,19 @@ import {
|
|
|
57
51
|
import { PositionListParams, PositionListResponse, Positions } from './resources/positions';
|
|
58
52
|
import { Price, PriceRetrieveParams, PriceRetrieveResponse } from './resources/price';
|
|
59
53
|
import { TradeListParams, TradeListResponse, Trades } from './resources/trades';
|
|
54
|
+
import {
|
|
55
|
+
Wallet,
|
|
56
|
+
WalletExportKeyParams,
|
|
57
|
+
WalletExportKeyResponse,
|
|
58
|
+
WalletRetrieveResponse,
|
|
59
|
+
} from './resources/wallet';
|
|
60
60
|
import {
|
|
61
61
|
CustomerUsage,
|
|
62
62
|
Websocket,
|
|
63
63
|
WebsocketUsageParams,
|
|
64
64
|
WebsocketUsageResponse,
|
|
65
65
|
} from './resources/websocket';
|
|
66
|
+
import { Builder, BuilderPoolResponse } from './resources/builder/builder';
|
|
66
67
|
import { type Fetch } from './internal/builtin-types';
|
|
67
68
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
68
69
|
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
@@ -164,11 +165,6 @@ export interface ClientOptions {
|
|
|
164
165
|
* Defaults to globalThis.console.
|
|
165
166
|
*/
|
|
166
167
|
logger?: Logger | undefined;
|
|
167
|
-
|
|
168
|
-
// TODO(verbose-mode): Add per-request debug override that logs raw request/response
|
|
169
|
-
// details (method, URL, headers, body, status) independent of global log level.
|
|
170
|
-
// pmxt exposes `verbose: true` per request, which is useful during strategy
|
|
171
|
-
// integration debugging without enabling global SDK logging noise.
|
|
172
168
|
}
|
|
173
169
|
|
|
174
170
|
/**
|
|
@@ -285,8 +281,8 @@ export class ParsecAPI {
|
|
|
285
281
|
return buildHeaders([{ 'X-API-Key': this.apiKey }]);
|
|
286
282
|
}
|
|
287
283
|
|
|
288
|
-
protected stringifyQuery(query: Record<string, unknown>): string {
|
|
289
|
-
return
|
|
284
|
+
protected stringifyQuery(query: object | Record<string, unknown>): string {
|
|
285
|
+
return stringifyQuery(query);
|
|
290
286
|
}
|
|
291
287
|
|
|
292
288
|
private getUserAgent(): string {
|
|
@@ -323,7 +319,7 @@ export class ParsecAPI {
|
|
|
323
319
|
}
|
|
324
320
|
|
|
325
321
|
if (typeof query === 'object' && query && !Array.isArray(query)) {
|
|
326
|
-
url.search = this.stringifyQuery(query
|
|
322
|
+
url.search = this.stringifyQuery(query);
|
|
327
323
|
}
|
|
328
324
|
|
|
329
325
|
return url.toString();
|
|
@@ -762,7 +758,7 @@ export class ParsecAPI {
|
|
|
762
758
|
) {
|
|
763
759
|
return {
|
|
764
760
|
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
765
|
-
body: this.stringifyQuery(body
|
|
761
|
+
body: this.stringifyQuery(body),
|
|
766
762
|
};
|
|
767
763
|
} else {
|
|
768
764
|
return this.#encoder({ body, headers });
|
|
@@ -798,42 +794,12 @@ export class ParsecAPI {
|
|
|
798
794
|
websocket: API.Websocket = new API.Websocket(this);
|
|
799
795
|
orders: API.Orders = new API.Orders(this);
|
|
800
796
|
positions: API.Positions = new API.Positions(this);
|
|
797
|
+
fills: API.Fills = new API.Fills(this);
|
|
801
798
|
account: API.Account = new API.Account(this);
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
* Inherits `apiKey` from this client and derives the WebSocket URL from `baseURL`.
|
|
807
|
-
*
|
|
808
|
-
* @param opts.url - Override the WebSocket URL (derived from baseURL by default).
|
|
809
|
-
* @returns A new `ParsecWebSocket` instance.
|
|
810
|
-
*
|
|
811
|
-
* @example
|
|
812
|
-
* ```ts
|
|
813
|
-
* const client = new ParsecAPI({ apiKey: 'pk_...' });
|
|
814
|
-
* const ws = client.ws();
|
|
815
|
-
*
|
|
816
|
-
* ws.on('orderbook', (book) => console.log(book.bids[0]));
|
|
817
|
-
* await ws.connect();
|
|
818
|
-
* ws.subscribe({ parsecId: 'polymarket:0x123', outcome: 'Yes' });
|
|
819
|
-
* ```
|
|
820
|
-
*/
|
|
821
|
-
ws(opts?: ParsecWebSocketOptions): ParsecWebSocket {
|
|
822
|
-
const wsUrl = opts?.url ?? this.#deriveWsUrl();
|
|
823
|
-
return new ParsecWebSocket(this.apiKey, wsUrl);
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
#deriveWsUrl(): string {
|
|
827
|
-
const base = this.baseURL.replace(/\/$/, '');
|
|
828
|
-
if (base.startsWith('https://')) {
|
|
829
|
-
return base.replace(/^https:\/\//, 'wss://') + '/ws';
|
|
830
|
-
}
|
|
831
|
-
if (base.startsWith('http://')) {
|
|
832
|
-
return base.replace(/^http:\/\//, 'ws://') + '/ws';
|
|
833
|
-
}
|
|
834
|
-
// Fallback: assume wss
|
|
835
|
-
return 'wss://' + base + '/ws';
|
|
836
|
-
}
|
|
799
|
+
onboard: API.Onboard = new API.Onboard(this);
|
|
800
|
+
wallet: API.Wallet = new API.Wallet(this);
|
|
801
|
+
ctf: API.Ctf = new API.Ctf(this);
|
|
802
|
+
builder: API.Builder = new API.Builder(this);
|
|
837
803
|
}
|
|
838
804
|
|
|
839
805
|
ParsecAPI.Exchanges = Exchanges;
|
|
@@ -846,8 +812,12 @@ ParsecAPI.Events = Events;
|
|
|
846
812
|
ParsecAPI.Websocket = Websocket;
|
|
847
813
|
ParsecAPI.Orders = Orders;
|
|
848
814
|
ParsecAPI.Positions = Positions;
|
|
815
|
+
ParsecAPI.Fills = Fills;
|
|
849
816
|
ParsecAPI.Account = Account;
|
|
850
|
-
ParsecAPI.
|
|
817
|
+
ParsecAPI.Onboard = Onboard;
|
|
818
|
+
ParsecAPI.Wallet = Wallet;
|
|
819
|
+
ParsecAPI.Ctf = Ctf;
|
|
820
|
+
ParsecAPI.Builder = Builder;
|
|
851
821
|
|
|
852
822
|
export declare namespace ParsecAPI {
|
|
853
823
|
export type RequestOptions = Opts.RequestOptions;
|
|
@@ -913,23 +883,39 @@ export declare namespace ParsecAPI {
|
|
|
913
883
|
type PositionListParams as PositionListParams,
|
|
914
884
|
};
|
|
915
885
|
|
|
886
|
+
export { Fills as Fills, type FillListResponse as FillListResponse, type FillListParams as FillListParams };
|
|
887
|
+
|
|
916
888
|
export {
|
|
917
889
|
Account as Account,
|
|
918
890
|
type AccountBalanceResponse as AccountBalanceResponse,
|
|
919
|
-
type AccountCapabilitiesResponse as AccountCapabilitiesResponse,
|
|
920
891
|
type AccountPingResponse as AccountPingResponse,
|
|
892
|
+
type AccountUsageResponse as AccountUsageResponse,
|
|
921
893
|
type AccountUserActivityResponse as AccountUserActivityResponse,
|
|
922
894
|
type AccountBalanceParams as AccountBalanceParams,
|
|
923
895
|
type AccountPingParams as AccountPingParams,
|
|
924
|
-
type AccountUpdateCredentialsParams as AccountUpdateCredentialsParams,
|
|
925
896
|
type AccountUserActivityParams as AccountUserActivityParams,
|
|
926
897
|
};
|
|
927
898
|
|
|
928
899
|
export {
|
|
929
|
-
|
|
930
|
-
type
|
|
931
|
-
type
|
|
932
|
-
type ApprovalListParams as ApprovalListParams,
|
|
933
|
-
type ApprovalSetParams as ApprovalSetParams,
|
|
900
|
+
Onboard as Onboard,
|
|
901
|
+
type OnboardCreateResponse as OnboardCreateResponse,
|
|
902
|
+
type OnboardCreateParams as OnboardCreateParams,
|
|
934
903
|
};
|
|
904
|
+
|
|
905
|
+
export {
|
|
906
|
+
Wallet as Wallet,
|
|
907
|
+
type WalletRetrieveResponse as WalletRetrieveResponse,
|
|
908
|
+
type WalletExportKeyResponse as WalletExportKeyResponse,
|
|
909
|
+
type WalletExportKeyParams as WalletExportKeyParams,
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
export {
|
|
913
|
+
Ctf as Ctf,
|
|
914
|
+
type CtfResponse as CtfResponse,
|
|
915
|
+
type CtfMergeParams as CtfMergeParams,
|
|
916
|
+
type CtfRedeemParams as CtfRedeemParams,
|
|
917
|
+
type CtfSplitParams as CtfSplitParams,
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
export { Builder as Builder, type BuilderPoolResponse as BuilderPoolResponse };
|
|
935
921
|
}
|
package/src/core/error.ts
CHANGED
|
@@ -23,35 +23,6 @@ export class APIError<
|
|
|
23
23
|
this.error = error;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
* Machine-readable error code from API response body, when provided.
|
|
28
|
-
* Example: `insufficient_funds`, `rate_limit_exceeded`.
|
|
29
|
-
*/
|
|
30
|
-
get code(): string | undefined {
|
|
31
|
-
const code = (this.error as any)?.code;
|
|
32
|
-
return typeof code === 'string' ? code : undefined;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Retry hint from API response body, when provided.
|
|
37
|
-
*/
|
|
38
|
-
get retryable(): boolean | undefined {
|
|
39
|
-
const retryable = (this.error as any)?.retryable;
|
|
40
|
-
return typeof retryable === 'boolean' ? retryable : undefined;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
isCode(code: string): boolean {
|
|
44
|
-
return this.code === code;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
isRetryable(): boolean {
|
|
48
|
-
return this.retryable === true;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
isInsufficientFunds(): boolean {
|
|
52
|
-
return this.code === 'insufficient_funds';
|
|
53
|
-
}
|
|
54
|
-
|
|
55
26
|
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
|
|
56
27
|
const msg =
|
|
57
28
|
error?.message ?
|
package/src/index.ts
CHANGED
|
@@ -20,17 +20,3 @@ export {
|
|
|
20
20
|
PermissionDeniedError,
|
|
21
21
|
UnprocessableEntityError,
|
|
22
22
|
} from './core/error';
|
|
23
|
-
|
|
24
|
-
export {
|
|
25
|
-
ParsecWebSocket,
|
|
26
|
-
type ParsecWebSocketOptions,
|
|
27
|
-
type ParsecWebSocketEventMap,
|
|
28
|
-
type OrderbookSnapshot,
|
|
29
|
-
type StreamingOrderbookLevel,
|
|
30
|
-
type Activity,
|
|
31
|
-
type WsError,
|
|
32
|
-
type MarketSubscription,
|
|
33
|
-
type FeedState,
|
|
34
|
-
type BookState,
|
|
35
|
-
type OrderbookKind,
|
|
36
|
-
} from './streaming';
|
package/src/internal/utils.ts
CHANGED
package/src/resources/account.ts
CHANGED
|
@@ -23,13 +23,6 @@ export class Account extends APIResource {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
* Returns the customer's tier and list of linked exchanges.
|
|
28
|
-
*/
|
|
29
|
-
capabilities(options?: RequestOptions): APIPromise<AccountCapabilitiesResponse> {
|
|
30
|
-
return this._client.get('/api/v1/session/capabilities', options);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
26
|
/**
|
|
34
27
|
* Performs a lightweight balance fetch per exchange to verify connectivity/auth
|
|
35
28
|
* status.
|
|
@@ -42,14 +35,12 @@ export class Account extends APIResource {
|
|
|
42
35
|
}
|
|
43
36
|
|
|
44
37
|
/**
|
|
45
|
-
*
|
|
38
|
+
* Returns the authenticated customer's tier, billing period, rate limits, and
|
|
39
|
+
* current consumption (monthly requests, WebSocket connections/subscriptions).
|
|
40
|
+
* Values of 0 for limits indicate unlimited.
|
|
46
41
|
*/
|
|
47
|
-
|
|
48
|
-
return this._client.
|
|
49
|
-
body,
|
|
50
|
-
...options,
|
|
51
|
-
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
52
|
-
});
|
|
42
|
+
usage(options?: RequestOptions): APIPromise<AccountUsageResponse> {
|
|
43
|
+
return this._client.get('/api/v1/usage', options);
|
|
53
44
|
}
|
|
54
45
|
|
|
55
46
|
/**
|
|
@@ -68,18 +59,6 @@ export interface AccountBalanceResponse {
|
|
|
68
59
|
raw: { [key: string]: unknown };
|
|
69
60
|
}
|
|
70
61
|
|
|
71
|
-
export interface AccountCapabilitiesResponse {
|
|
72
|
-
/**
|
|
73
|
-
* Exchange IDs the customer has credentials linked for.
|
|
74
|
-
*/
|
|
75
|
-
linked_exchanges: Array<string>;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Customer tier (e.g., "free", "pro", "admin").
|
|
79
|
-
*/
|
|
80
|
-
tier: string;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
62
|
export type AccountPingResponse = Array<AccountPingResponse.AccountPingResponseItem>;
|
|
84
63
|
|
|
85
64
|
export namespace AccountPingResponse {
|
|
@@ -94,6 +73,78 @@ export namespace AccountPingResponse {
|
|
|
94
73
|
}
|
|
95
74
|
}
|
|
96
75
|
|
|
76
|
+
export interface AccountUsageResponse {
|
|
77
|
+
/**
|
|
78
|
+
* Unix seconds — 1st of next month UTC.
|
|
79
|
+
*/
|
|
80
|
+
billing_period_end: number;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Unix seconds — 1st of current month UTC.
|
|
84
|
+
*/
|
|
85
|
+
billing_period_start: number;
|
|
86
|
+
|
|
87
|
+
limits: AccountUsageResponse.Limits;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Current tier (free, pro, scale).
|
|
91
|
+
*/
|
|
92
|
+
tier: string;
|
|
93
|
+
|
|
94
|
+
usage: AccountUsageResponse.Usage;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export namespace AccountUsageResponse {
|
|
98
|
+
export interface Limits {
|
|
99
|
+
/**
|
|
100
|
+
* Max historical data age in days. 0 = unlimited.
|
|
101
|
+
*/
|
|
102
|
+
history_max_age_days: number;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Monthly REST request cap. 0 = unlimited.
|
|
106
|
+
*/
|
|
107
|
+
monthly_requests: number;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* REST queries per second. 0 = unlimited.
|
|
111
|
+
*/
|
|
112
|
+
rest_qps: number;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* REST burst QPS allowance. 0 = unlimited.
|
|
116
|
+
*/
|
|
117
|
+
rest_qps_burst: number;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Max orderbook depth per WebSocket subscription.
|
|
121
|
+
*/
|
|
122
|
+
ws_max_depth: number;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Max WebSocket subscriptions across all connections. 0 = unlimited.
|
|
126
|
+
*/
|
|
127
|
+
ws_max_subscriptions: number;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface Usage {
|
|
131
|
+
/**
|
|
132
|
+
* REST requests consumed this billing period.
|
|
133
|
+
*/
|
|
134
|
+
monthly_requests: number;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Currently active WebSocket connections.
|
|
138
|
+
*/
|
|
139
|
+
ws_active_connections: number;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Currently active WebSocket subscriptions.
|
|
143
|
+
*/
|
|
144
|
+
ws_active_subscriptions: number;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
97
148
|
export interface AccountUserActivityResponse {
|
|
98
149
|
exchanges: { [key: string]: unknown };
|
|
99
150
|
|
|
@@ -134,33 +185,6 @@ export interface AccountPingParams {
|
|
|
134
185
|
exchange?: string;
|
|
135
186
|
}
|
|
136
187
|
|
|
137
|
-
export interface AccountUpdateCredentialsParams {
|
|
138
|
-
/**
|
|
139
|
-
* Kalshi API key ID.
|
|
140
|
-
*/
|
|
141
|
-
api_key_id?: string | null;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Polymarket CLOB API key.
|
|
145
|
-
*/
|
|
146
|
-
clob_api_key?: string | null;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Polymarket CLOB API passphrase.
|
|
150
|
-
*/
|
|
151
|
-
clob_api_passphrase?: string | null;
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Polymarket CLOB API secret.
|
|
155
|
-
*/
|
|
156
|
-
clob_api_secret?: string | null;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Kalshi RSA private key (PEM format).
|
|
160
|
-
*/
|
|
161
|
-
private_key?: string | null;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
188
|
export interface AccountUserActivityParams {
|
|
165
189
|
/**
|
|
166
190
|
* User address (typically an EVM address).
|
|
@@ -182,12 +206,11 @@ export interface AccountUserActivityParams {
|
|
|
182
206
|
export declare namespace Account {
|
|
183
207
|
export {
|
|
184
208
|
type AccountBalanceResponse as AccountBalanceResponse,
|
|
185
|
-
type AccountCapabilitiesResponse as AccountCapabilitiesResponse,
|
|
186
209
|
type AccountPingResponse as AccountPingResponse,
|
|
210
|
+
type AccountUsageResponse as AccountUsageResponse,
|
|
187
211
|
type AccountUserActivityResponse as AccountUserActivityResponse,
|
|
188
212
|
type AccountBalanceParams as AccountBalanceParams,
|
|
189
213
|
type AccountPingParams as AccountPingParams,
|
|
190
|
-
type AccountUpdateCredentialsParams as AccountUpdateCredentialsParams,
|
|
191
214
|
type AccountUserActivityParams as AccountUserActivityParams,
|
|
192
215
|
};
|
|
193
216
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import * as EscrowAPI from './escrow';
|
|
5
|
+
import { Escrow, EscrowConfigResponse } from './escrow';
|
|
6
|
+
import * as OnboardAPI from './onboard';
|
|
7
|
+
import { Onboard, OnboardCreateParams, OnboardCreateResponse } from './onboard';
|
|
8
|
+
import * as UsersAPI from './users';
|
|
9
|
+
import {
|
|
10
|
+
UserCreateParams,
|
|
11
|
+
UserCreateResponse,
|
|
12
|
+
UserListParams,
|
|
13
|
+
UserListResponse,
|
|
14
|
+
UserRetrieveResponse,
|
|
15
|
+
UserUpdateParams,
|
|
16
|
+
UserUpdateResponse,
|
|
17
|
+
Users,
|
|
18
|
+
} from './users';
|
|
19
|
+
import { APIPromise } from '../../core/api-promise';
|
|
20
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
21
|
+
|
|
22
|
+
export class Builder extends APIResource {
|
|
23
|
+
users: UsersAPI.Users = new UsersAPI.Users(this._client);
|
|
24
|
+
onboard: OnboardAPI.Onboard = new OnboardAPI.Onboard(this._client);
|
|
25
|
+
escrow: EscrowAPI.Escrow = new EscrowAPI.Escrow(this._client);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns the builder's QPS pool allocation, end-user count, and total allocated
|
|
29
|
+
* QPS.
|
|
30
|
+
*/
|
|
31
|
+
pool(options?: RequestOptions): APIPromise<BuilderPoolResponse> {
|
|
32
|
+
return this._client.get('/api/v1/builder/pool', options);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface BuilderPoolResponse {
|
|
37
|
+
/**
|
|
38
|
+
* Number of end-users created by this builder.
|
|
39
|
+
*/
|
|
40
|
+
end_user_count: number;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Total QPS available to this builder.
|
|
44
|
+
*/
|
|
45
|
+
qps_pool: number;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Total QPS allocated to end-users.
|
|
49
|
+
*/
|
|
50
|
+
total_allocated_qps: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
Builder.Users = Users;
|
|
54
|
+
Builder.Onboard = Onboard;
|
|
55
|
+
Builder.Escrow = Escrow;
|
|
56
|
+
|
|
57
|
+
export declare namespace Builder {
|
|
58
|
+
export { type BuilderPoolResponse as BuilderPoolResponse };
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
Users as Users,
|
|
62
|
+
type UserCreateResponse as UserCreateResponse,
|
|
63
|
+
type UserRetrieveResponse as UserRetrieveResponse,
|
|
64
|
+
type UserUpdateResponse as UserUpdateResponse,
|
|
65
|
+
type UserListResponse as UserListResponse,
|
|
66
|
+
type UserCreateParams as UserCreateParams,
|
|
67
|
+
type UserUpdateParams as UserUpdateParams,
|
|
68
|
+
type UserListParams as UserListParams,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
Onboard as Onboard,
|
|
73
|
+
type OnboardCreateResponse as OnboardCreateResponse,
|
|
74
|
+
type OnboardCreateParams as OnboardCreateParams,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { Escrow as Escrow, type EscrowConfigResponse as EscrowConfigResponse };
|
|
78
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import { APIPromise } from '../../core/api-promise';
|
|
5
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
6
|
+
|
|
7
|
+
export class Escrow extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* Returns the builder's fee escrow configuration including contract address, fee
|
|
10
|
+
* rates, and treasury address. Read-only — fee escrow is configured by Parsec
|
|
11
|
+
* admins during onboarding.
|
|
12
|
+
*/
|
|
13
|
+
config(options?: RequestOptions): APIPromise<EscrowConfigResponse> {
|
|
14
|
+
return this._client.get('/api/v1/builder/escrow/config', options);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface EscrowConfigResponse {
|
|
19
|
+
/**
|
|
20
|
+
* Affiliate fee rate in basis points.
|
|
21
|
+
*/
|
|
22
|
+
affiliate_fee_bps: number;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Escrow smart contract address.
|
|
26
|
+
*/
|
|
27
|
+
escrow_contract_address: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Whether fee escrow is enabled for this builder.
|
|
31
|
+
*/
|
|
32
|
+
fee_escrow_enabled: boolean;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Minimum fee in basis points.
|
|
36
|
+
*/
|
|
37
|
+
min_fee_bps: number;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Minimum fee in USDC (human-readable).
|
|
41
|
+
*/
|
|
42
|
+
min_fee_usdc: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Treasury address for fee distribution.
|
|
46
|
+
*/
|
|
47
|
+
treasury_address: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Affiliate fee recipient address.
|
|
51
|
+
*/
|
|
52
|
+
affiliate_address?: string | null;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Fee rate in basis points.
|
|
56
|
+
*/
|
|
57
|
+
fee_bps?: number | null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export declare namespace Escrow {
|
|
61
|
+
export { type EscrowConfigResponse as EscrowConfigResponse };
|
|
62
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
export { Builder, type BuilderPoolResponse } from './builder';
|
|
4
|
+
export { Escrow, type EscrowConfigResponse } from './escrow';
|
|
5
|
+
export { Onboard, type OnboardCreateResponse, type OnboardCreateParams } from './onboard';
|
|
6
|
+
export {
|
|
7
|
+
Users,
|
|
8
|
+
type UserCreateResponse,
|
|
9
|
+
type UserRetrieveResponse,
|
|
10
|
+
type UserUpdateResponse,
|
|
11
|
+
type UserListResponse,
|
|
12
|
+
type UserCreateParams,
|
|
13
|
+
type UserUpdateParams,
|
|
14
|
+
type UserListParams,
|
|
15
|
+
} from './users';
|