@jsnw/kalshi-client 0.0.1 → 0.2.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/index.d.mts CHANGED
@@ -1,12 +1,7 @@
1
1
  import { z } from "zod";
2
+ import { ApiClient as ApiClient$1, ApiClientConfig as ApiClientConfig$1, ApiRawRequest, HttpMethod } from "@jsnw/api-client";
2
3
  import { Agent } from "node:http";
3
4
 
4
- //#region src/consts.d.ts
5
- declare const HTTP_METHOD: readonly ["get", "post", "put", "patch", "delete", "head", "options"];
6
- declare const KALSHI_ENVIRONMENT: readonly ["development", "production"];
7
- type HttpMethod = typeof HTTP_METHOD[number] | Uppercase<typeof HTTP_METHOD[number]>;
8
- type KalshiEnvironment = typeof KALSHI_ENVIRONMENT[number];
9
- //#endregion
10
5
  //#region src/request-signer.d.ts
11
6
  interface SignatureParameters {
12
7
  timestamp: Date | number;
@@ -90,8 +85,59 @@ declare const primitives$orderActionSchema: z.ZodEnum<{
90
85
  sell: "sell";
91
86
  }>;
92
87
  type Primitives$OrderAction = z.infer<typeof primitives$orderActionSchema>;
88
+ declare const primitives$rateLimitBucketMetaSchema: z.ZodObject<{
89
+ refill_rate: z.ZodNumber;
90
+ bucket_capacity: z.ZodNumber;
91
+ }, z.core.$strip>;
92
+ type Primitives$RateLimitBucketMeta = z.infer<typeof primitives$rateLimitBucketMetaSchema>;
93
+ //#endregion
94
+ //#region src/schemas/http.d.ts
95
+ declare const http$errorMessageSchema: z.ZodObject<{
96
+ code: z.ZodNumber;
97
+ message: z.ZodOptional<z.ZodString>;
98
+ details: z.ZodOptional<z.ZodAny>;
99
+ service: z.ZodOptional<z.ZodAny>;
100
+ }, z.core.$strip>;
101
+ type Http$ErrorMessage = z.infer<typeof http$errorMessageSchema>;
102
+ //#endregion
103
+ //#region src/schemas/account.d.ts
104
+ declare const account$accountTierSchema: z.ZodEnum<{
105
+ basic: "basic";
106
+ advanced: "advanced";
107
+ expert: "expert";
108
+ premier: "premier";
109
+ paragon: "paragon";
110
+ prime: "prime";
111
+ prestige: "prestige";
112
+ }>;
113
+ type Account$AccountTier = z.infer<typeof account$accountTierSchema>;
114
+ declare const account$subaccountSchema: z.ZodDefault<z.ZodNumber>;
115
+ type Account$Subaccount = z.infer<typeof account$subaccountSchema>;
116
+ declare const account$accountGrantSchema: z.ZodObject<{
117
+ exchange_instance: z.ZodEnum<{
118
+ event_contract: "event_contract";
119
+ margined: "margined";
120
+ }>;
121
+ level: z.ZodEnum<{
122
+ basic: "basic";
123
+ advanced: "advanced";
124
+ expert: "expert";
125
+ premier: "premier";
126
+ paragon: "paragon";
127
+ prime: "prime";
128
+ prestige: "prestige";
129
+ }>;
130
+ source: z.ZodEnum<{
131
+ volume: "volume";
132
+ manual: "manual";
133
+ }>;
134
+ expires_ts: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
135
+ }, z.core.$strip>;
136
+ type Account$AccountGrant = z.infer<typeof account$accountGrantSchema>;
93
137
  //#endregion
94
138
  //#region src/schemas/orders.d.ts
139
+ declare const orders$clientOrderIdSchema: z.ZodOptional<z.ZodNullable<z.ZodString>>;
140
+ type Orders$ClientOrderId = z.infer<typeof orders$clientOrderIdSchema>;
95
141
  declare const orders$orderStatusSchema: z.ZodEnum<{
96
142
  resting: "resting";
97
143
  canceled: "canceled";
@@ -108,14 +154,24 @@ declare const orders$selfTradePreventionTypeSchema: z.ZodEnum<{
108
154
  maker: "maker";
109
155
  }>;
110
156
  type orders$SelfTradePreventionType = z.infer<typeof orders$selfTradePreventionTypeSchema>;
157
+ declare const orders$timeInForceSchema: z.ZodEnum<{
158
+ fill_or_kill: "fill_or_kill";
159
+ good_till_canceled: "good_till_canceled";
160
+ immediate_or_cancel: "immediate_or_cancel";
161
+ }>;
162
+ type Orders$TimeInForce = z.infer<typeof orders$timeInForceSchema>;
111
163
  declare const orders$orderDetailedSchema: z.ZodObject<{
112
164
  order_id: z.ZodUUID;
113
165
  user_id: z.ZodUUID;
166
+ client_order_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
167
+ order_group_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
114
168
  subaccount_number: z.ZodDefault<z.ZodNumber>;
115
- order_group_id: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
116
169
  exchange_index: z.ZodDefault<z.ZodNumber>;
117
- client_order_id: z.ZodString;
118
170
  ticker: z.ZodString;
171
+ type: z.ZodEnum<{
172
+ limit: "limit";
173
+ market: "market";
174
+ }>;
119
175
  outcome_side: z.ZodEnum<{
120
176
  yes: "yes";
121
177
  no: "no";
@@ -124,10 +180,6 @@ declare const orders$orderDetailedSchema: z.ZodObject<{
124
180
  bid: "bid";
125
181
  ask: "ask";
126
182
  }>;
127
- type: z.ZodEnum<{
128
- limit: "limit";
129
- market: "market";
130
- }>;
131
183
  status: z.ZodEnum<{
132
184
  resting: "resting";
133
185
  canceled: "canceled";
@@ -142,17 +194,20 @@ declare const orders$orderDetailedSchema: z.ZodObject<{
142
194
  maker_fill_cost_dollars: z.ZodString;
143
195
  taker_fees_dollars: z.ZodString;
144
196
  maker_fees_dollars: z.ZodString;
145
- self_trade_prevention_type: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
197
+ self_trade_prevention_type: z.ZodEnum<{
146
198
  taker_at_cross: "taker_at_cross";
147
199
  maker: "maker";
148
- }>>>;
200
+ }>;
149
201
  cancel_order_on_pause: z.ZodBoolean;
150
202
  created_time: z.ZodISODateTime;
151
- expiration_time: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
152
203
  last_update_time: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
204
+ expiration_time: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
153
205
  }, z.core.$strip>;
154
206
  type Orders$OrderDetailed = z.infer<typeof orders$orderDetailedSchema>;
155
207
  declare const orders$orderWsSchema: z.ZodObject<{
208
+ order_id: z.ZodUUID;
209
+ client_order_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
210
+ subaccount_number: z.ZodDefault<z.ZodNumber>;
156
211
  outcome_side: z.ZodEnum<{
157
212
  yes: "yes";
158
213
  no: "no";
@@ -174,19 +229,16 @@ declare const orders$orderWsSchema: z.ZodObject<{
174
229
  maker_fill_cost_dollars: z.ZodString;
175
230
  taker_fees_dollars: z.ZodString;
176
231
  maker_fees_dollars: z.ZodString;
177
- order_id: z.ZodUUID;
178
- user_id: z.ZodUUID;
179
- subaccount_number: z.ZodDefault<z.ZodNumber>;
180
- order_group_id: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
181
- client_order_id: z.ZodString;
182
- ticker: z.ZodString;
183
- self_trade_prevention_type: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
232
+ self_trade_prevention_type: z.ZodEnum<{
184
233
  taker_at_cross: "taker_at_cross";
185
234
  maker: "maker";
186
- }>>>;
235
+ }>;
236
+ user_id: z.ZodUUID;
237
+ order_group_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
238
+ ticker: z.ZodString;
187
239
  created_time: z.ZodISODateTime;
188
- expiration_time: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
189
240
  last_update_time: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
241
+ expiration_time: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
190
242
  side: z.ZodEnum<{
191
243
  yes: "yes";
192
244
  no: "no";
@@ -196,6 +248,33 @@ declare const orders$orderWsSchema: z.ZodObject<{
196
248
  expiration_ts_ms: z.ZodOptional<z.ZodNumber>;
197
249
  }, z.core.$strip>;
198
250
  type Orders$OrderWs = z.infer<typeof orders$orderWsSchema>;
251
+ declare const orders$createOrderDtoSchema: z.ZodObject<{
252
+ client_order_id: z.ZodOptional<z.ZodString>;
253
+ order_group_id: z.ZodOptional<z.ZodString>;
254
+ exchange_index: z.ZodDefault<z.ZodNumber>;
255
+ ticker: z.ZodString;
256
+ side: z.ZodEnum<{
257
+ bid: "bid";
258
+ ask: "ask";
259
+ }>;
260
+ count: z.ZodString;
261
+ subaccount: z.ZodDefault<z.ZodNumber>;
262
+ price: z.ZodString;
263
+ post_only: z.ZodDefault<z.ZodBoolean>;
264
+ reduce_only: z.ZodDefault<z.ZodBoolean>;
265
+ cancel_order_on_pause: z.ZodBoolean;
266
+ self_trade_prevention_type: z.ZodEnum<{
267
+ taker_at_cross: "taker_at_cross";
268
+ maker: "maker";
269
+ }>;
270
+ time_in_force: z.ZodEnum<{
271
+ fill_or_kill: "fill_or_kill";
272
+ good_till_canceled: "good_till_canceled";
273
+ immediate_or_cancel: "immediate_or_cancel";
274
+ }>;
275
+ expiration_time: z.ZodOptional<z.ZodNumber>;
276
+ }, z.core.$strip>;
277
+ type Orders$CreateOrderDto = z.input<typeof orders$createOrderDtoSchema>;
199
278
  //#endregion
200
279
  //#region src/typed-emitter.d.ts
201
280
  type Listener<T extends unknown[]> = (...args: T) => void;
@@ -211,6 +290,10 @@ declare class TypedEmitter<TEvents extends Record<string, unknown[]>> {
211
290
  listenersCount<K extends keyof TEvents>(event?: K): number;
212
291
  }
213
292
  //#endregion
293
+ //#region src/consts.d.ts
294
+ declare const KALSHI_ENVIRONMENT: readonly ["development", "production"];
295
+ type KalshiEnvironment = typeof KALSHI_ENVIRONMENT[number];
296
+ //#endregion
214
297
  //#region src/ws-wrapper/types.d.ts
215
298
  type HeadersFn = () => Record<string, string>;
216
299
  type ReconnectStrategy = ((attempt: number) => number | false) | {
@@ -240,84 +323,6 @@ interface WsClientOptions {
240
323
  log?: LogFunction;
241
324
  }
242
325
  //#endregion
243
- //#region src/ws/ws-client.d.ts
244
- declare class WsClient extends TypedEmitter<any> {
245
- readonly id: string;
246
- private readonly baseURL;
247
- private readonly credentialsProvider;
248
- private readonly log;
249
- private readonly ws;
250
- private lastMessageId;
251
- private readonly subscribeAwaiters;
252
- /**
253
- * @param {WsClientOptions} options
254
- */
255
- constructor(options: WsClientOptions);
256
- private onReady;
257
- /**
258
- * @param {WebSocket.RawData} data
259
- * @param {boolean} isBinary
260
- * @return {Promise<void>}
261
- */
262
- private onMessage;
263
- /**
264
- * @param {number} attempt
265
- */
266
- private onReconnecting;
267
- /**
268
- * @param {Error} err
269
- */
270
- private onError;
271
- /**
272
- */
273
- private onClose;
274
- /**
275
- * @param {WsAnyMessage} msg
276
- * @private
277
- */
278
- private processMessage;
279
- }
280
- //#endregion
281
- //#region src/ws/errors.d.ts
282
- declare class WsKalshiError extends Error {
283
- readonly id: number;
284
- readonly code: number;
285
- /**
286
- * @param {number} id
287
- * @param {number} code
288
- * @param {string} message
289
- */
290
- constructor(id: number, code: number, message?: string);
291
- }
292
- //#endregion
293
- //#region src/ws/common.d.ts
294
- declare const WS_KALSHI_ERRORS: {
295
- readonly UNABLE_TO_PROCESS: 1;
296
- readonly PARAMS_REQUIRED: 2;
297
- readonly CHANNELS_REQUIRED: 3;
298
- readonly SUBSCRIPTION_IDS_REQUIRED: 4;
299
- readonly UNKNOWN_COMMAND: 5;
300
- readonly ALREADY_SUBSCRIBED: 6;
301
- readonly UNKNOWN_SUBSCRIPTION_ID: 7;
302
- readonly UNKNOWN_CHANNEL_NAME: 8;
303
- readonly AUTHENTICATION_REQUIRED: 9;
304
- readonly CHANNEL_ERROR: 10;
305
- readonly INVALID_PARAMETER: 11;
306
- readonly EXACTLY_ONE_SUBSCRIPTION_ID_IS_REQUIRED: 12;
307
- readonly UNSUPPORTED_ACTION: 13;
308
- readonly MARKET_TICKER_REQUIRED: 14;
309
- readonly ACTION_REQUIRED: 15;
310
- readonly MARKET_NOT_FOUND: 16;
311
- readonly INTERNAL_ERROR: 17;
312
- readonly COMMAND_TIMEOUT: 18;
313
- readonly SHARD_FACTOR_MUST_BE_GT0: 19;
314
- readonly SHARD_FACTOR_IS_REQUIRED: 20;
315
- readonly INVALID_SHARD_KEY: 21;
316
- readonly SHARD_FACTOR_MUST_BE_LT100: 22;
317
- readonly SUBSCRIPTION_BUFFER_OVERFLOW: 25;
318
- };
319
- declare const WS_KALSHI_SERVER_ERRORS: number[];
320
- //#endregion
321
326
  //#region src/ws/messages.d.ts
322
327
  declare const wsOkMessageSchema: z.ZodObject<{
323
328
  id: z.ZodNumber;
@@ -348,6 +353,9 @@ declare const wsUserOrderMessageSchema: z.ZodObject<{
348
353
  sid: z.ZodNumber;
349
354
  type: z.ZodLiteral<"user_order">;
350
355
  msg: z.ZodObject<{
356
+ order_id: z.ZodUUID;
357
+ client_order_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
358
+ subaccount_number: z.ZodDefault<z.ZodNumber>;
351
359
  outcome_side: z.ZodEnum<{
352
360
  yes: "yes";
353
361
  no: "no";
@@ -369,19 +377,16 @@ declare const wsUserOrderMessageSchema: z.ZodObject<{
369
377
  maker_fill_cost_dollars: z.ZodString;
370
378
  taker_fees_dollars: z.ZodString;
371
379
  maker_fees_dollars: z.ZodString;
372
- order_id: z.ZodUUID;
373
- user_id: z.ZodUUID;
374
- subaccount_number: z.ZodDefault<z.ZodNumber>;
375
- order_group_id: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
376
- client_order_id: z.ZodString;
377
- ticker: z.ZodString;
378
- self_trade_prevention_type: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
380
+ self_trade_prevention_type: z.ZodEnum<{
379
381
  taker_at_cross: "taker_at_cross";
380
382
  maker: "maker";
381
- }>>>;
383
+ }>;
384
+ user_id: z.ZodUUID;
385
+ order_group_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
386
+ ticker: z.ZodString;
382
387
  created_time: z.ZodISODateTime;
383
- expiration_time: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
384
388
  last_update_time: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
389
+ expiration_time: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
385
390
  side: z.ZodEnum<{
386
391
  yes: "yes";
387
392
  no: "no";
@@ -415,6 +420,9 @@ declare const wsAnyMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
415
420
  sid: z.ZodNumber;
416
421
  type: z.ZodLiteral<"user_order">;
417
422
  msg: z.ZodObject<{
423
+ order_id: z.ZodUUID;
424
+ client_order_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
425
+ subaccount_number: z.ZodDefault<z.ZodNumber>;
418
426
  outcome_side: z.ZodEnum<{
419
427
  yes: "yes";
420
428
  no: "no";
@@ -436,19 +444,16 @@ declare const wsAnyMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
436
444
  maker_fill_cost_dollars: z.ZodString;
437
445
  taker_fees_dollars: z.ZodString;
438
446
  maker_fees_dollars: z.ZodString;
439
- order_id: z.ZodUUID;
440
- user_id: z.ZodUUID;
441
- subaccount_number: z.ZodDefault<z.ZodNumber>;
442
- order_group_id: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
443
- client_order_id: z.ZodString;
444
- ticker: z.ZodString;
445
- self_trade_prevention_type: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
447
+ self_trade_prevention_type: z.ZodEnum<{
446
448
  taker_at_cross: "taker_at_cross";
447
449
  maker: "maker";
448
- }>>>;
450
+ }>;
451
+ user_id: z.ZodUUID;
452
+ order_group_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
453
+ ticker: z.ZodString;
449
454
  created_time: z.ZodISODateTime;
450
- expiration_time: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
451
455
  last_update_time: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
456
+ expiration_time: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
452
457
  side: z.ZodEnum<{
453
458
  yes: "yes";
454
459
  no: "no";
@@ -460,4 +465,445 @@ declare const wsAnyMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
460
465
  }, z.core.$strip>], "type">;
461
466
  type WsAnyMessage = z.infer<typeof wsAnyMessageSchema>;
462
467
  //#endregion
463
- export { type ICredentialsProvider, type IRequestSigner, InMemoryCredentialsProvider, type InMemoryCredentialsProviderOptions, Orders$OrderDetailed, Orders$OrderStatus, Orders$OrderWs, Primitives$BookSide, Primitives$FixedPoint, Primitives$OrderAction, Primitives$OrderSide, RequestSigner, type RequestSignerOptions, type SignatureParameters, WS_KALSHI_ERRORS, WS_KALSHI_SERVER_ERRORS, WsAnyMessage, WsClient, type WsClientOptions, WsErrorMessage, WsKalshiError, WsOkMessage, WsSubscribedMessage, WsUserOrderMessage, orders$OrderType, orders$SelfTradePreventionType, orders$orderDetailedSchema, orders$orderStatusSchema, orders$orderTypeSchema, orders$orderWsSchema, orders$selfTradePreventionTypeSchema, primitives$bookSideSchema, primitives$fixedPointSchema, primitives$orderActionSchema, primitives$orderSideSchema, wsAnyMessageSchema, wsErrorMessageSchema, wsOkMessageSchema, wsSubscribedMessageSchema, wsUserOrderMessageSchema };
468
+ //#region src/ws/subscription.d.ts
469
+ type UpdateSubscription = 'add_markets' | 'delete_markets';
470
+ type SubscriptionOptions = {
471
+ timeoutMs?: number;
472
+ } & ({
473
+ channel: 'orderbook_delta';
474
+ market_tickers: string[];
475
+ update_subscription?: UpdateSubscription & 'get_snapshot';
476
+ } | {
477
+ channel: 'ticker';
478
+ market_ids?: string[];
479
+ market_tickers?: string[];
480
+ } | {
481
+ channel: 'trade';
482
+ } | {
483
+ channel: 'fill';
484
+ market_tickers?: string[];
485
+ update_subscription?: UpdateSubscription;
486
+ } | {
487
+ channel: 'market_positions';
488
+ market_tickers?: string[];
489
+ } | {
490
+ channel: 'market_lifecycle_v2';
491
+ } | {
492
+ channel: 'multivariative_market_lifecycle';
493
+ } | {
494
+ channel: 'order_group_updates';
495
+ } | {
496
+ channel: 'user_orders';
497
+ market_tickers?: string[];
498
+ update_subscription?: UpdateSubscription;
499
+ });
500
+ //#endregion
501
+ //#region src/ws/ws-client.d.ts
502
+ declare class WsClient extends TypedEmitter<WsClientEvents> {
503
+ readonly id: string;
504
+ private readonly baseURL;
505
+ private readonly credentialsProvider;
506
+ private readonly log;
507
+ private readonly ws;
508
+ private lastMessageId;
509
+ private readonly subscribeAwaiters;
510
+ /**
511
+ * @param {WsClientOptions} options
512
+ */
513
+ constructor(options: WsClientOptions);
514
+ /**
515
+ * @return {Promise<void>}
516
+ */
517
+ connect(): Promise<void>;
518
+ /**
519
+ * @return {Promise<void>}
520
+ */
521
+ subscribe(options: SubscriptionOptions): Promise<void>;
522
+ /**
523
+ * @return {Promise<void>}
524
+ */
525
+ close(): Promise<void>;
526
+ private onReady;
527
+ /**
528
+ * @param {WebSocket.RawData} data
529
+ * @param {boolean} isBinary
530
+ * @return {Promise<void>}
531
+ */
532
+ private onMessage;
533
+ /**
534
+ * @param {number} attempt
535
+ */
536
+ private onReconnecting;
537
+ /**
538
+ * @param {Error} err
539
+ */
540
+ private onError;
541
+ /**
542
+ */
543
+ private onClose;
544
+ /**
545
+ * @param {WsAnyMessage} msg
546
+ * @private
547
+ */
548
+ private processMessage;
549
+ }
550
+ type WsClientEvents = {
551
+ ready: [afterReconnect: boolean];
552
+ reconnect: [attempt: number];
553
+ message: [msg: WsAnyMessage];
554
+ ws_error: [error: Error];
555
+ close: [];
556
+ };
557
+ //#endregion
558
+ //#region src/ws/errors.d.ts
559
+ declare class WsKalshiError extends Error {
560
+ readonly id: number;
561
+ readonly code: number;
562
+ /**
563
+ * @param {number} id
564
+ * @param {number} code
565
+ * @param {string} message
566
+ */
567
+ constructor(id: number, code: number, message?: string);
568
+ }
569
+ declare class WsClosedError extends Error {}
570
+ declare class WsClosedByUserError extends Error {}
571
+ //#endregion
572
+ //#region src/ws/common.d.ts
573
+ declare const WS_KALSHI_ERRORS: {
574
+ readonly UNABLE_TO_PROCESS: 1;
575
+ readonly PARAMS_REQUIRED: 2;
576
+ readonly CHANNELS_REQUIRED: 3;
577
+ readonly SUBSCRIPTION_IDS_REQUIRED: 4;
578
+ readonly UNKNOWN_COMMAND: 5;
579
+ readonly ALREADY_SUBSCRIBED: 6;
580
+ readonly UNKNOWN_SUBSCRIPTION_ID: 7;
581
+ readonly UNKNOWN_CHANNEL_NAME: 8;
582
+ readonly AUTHENTICATION_REQUIRED: 9;
583
+ readonly CHANNEL_ERROR: 10;
584
+ readonly INVALID_PARAMETER: 11;
585
+ readonly EXACTLY_ONE_SUBSCRIPTION_ID_IS_REQUIRED: 12;
586
+ readonly UNSUPPORTED_ACTION: 13;
587
+ readonly MARKET_TICKER_REQUIRED: 14;
588
+ readonly ACTION_REQUIRED: 15;
589
+ readonly MARKET_NOT_FOUND: 16;
590
+ readonly INTERNAL_ERROR: 17;
591
+ readonly COMMAND_TIMEOUT: 18;
592
+ readonly SHARD_FACTOR_MUST_BE_GT0: 19;
593
+ readonly SHARD_FACTOR_IS_REQUIRED: 20;
594
+ readonly INVALID_SHARD_KEY: 21;
595
+ readonly SHARD_FACTOR_MUST_BE_LT100: 22;
596
+ readonly SUBSCRIPTION_BUFFER_OVERFLOW: 25;
597
+ };
598
+ declare const WS_KALSHI_SERVER_ERRORS: number[];
599
+ //#endregion
600
+ //#region src/api/router/index.d.ts
601
+ declare const apiRouter: {
602
+ exchange: {
603
+ getStatus: {
604
+ method: "get";
605
+ path: string;
606
+ responses: {
607
+ 200: import("zod").ZodObject<{
608
+ exchange_active: import("zod").ZodBoolean;
609
+ trading_active: import("zod").ZodBoolean;
610
+ exchange_estimated_resume_time: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodISODateTime>>;
611
+ }, import("zod/v4/core").$strip>;
612
+ };
613
+ };
614
+ getUserDataTimestamp: {
615
+ method: "get";
616
+ path: string;
617
+ responses: {
618
+ 200: import("zod").ZodObject<{
619
+ as_of_time: import("zod").ZodISODateTime;
620
+ }, import("zod/v4/core").$strip>;
621
+ };
622
+ };
623
+ };
624
+ account: {
625
+ getLimits: {
626
+ method: "get";
627
+ path: string;
628
+ responses: {
629
+ 200: import("zod").ZodObject<{
630
+ usage_tier: import("zod").ZodEnum<{
631
+ basic: "basic";
632
+ advanced: "advanced";
633
+ expert: "expert";
634
+ premier: "premier";
635
+ paragon: "paragon";
636
+ prime: "prime";
637
+ prestige: "prestige";
638
+ }>;
639
+ read: import("zod").ZodObject<{
640
+ refill_rate: import("zod").ZodNumber;
641
+ bucket_capacity: import("zod").ZodNumber;
642
+ }, import("zod/v4/core").$strip>;
643
+ write: import("zod").ZodObject<{
644
+ refill_rate: import("zod").ZodNumber;
645
+ bucket_capacity: import("zod").ZodNumber;
646
+ }, import("zod/v4/core").$strip>;
647
+ grants: import("zod").ZodArray<import("zod").ZodObject<{
648
+ exchange_instance: import("zod").ZodEnum<{
649
+ event_contract: "event_contract";
650
+ margined: "margined";
651
+ }>;
652
+ level: import("zod").ZodEnum<{
653
+ basic: "basic";
654
+ advanced: "advanced";
655
+ expert: "expert";
656
+ premier: "premier";
657
+ paragon: "paragon";
658
+ prime: "prime";
659
+ prestige: "prestige";
660
+ }>;
661
+ source: import("zod").ZodEnum<{
662
+ volume: "volume";
663
+ manual: "manual";
664
+ }>;
665
+ expires_ts: import("zod").ZodDefault<import("zod").ZodNullable<import("zod").ZodNumber>>;
666
+ }, import("zod/v4/core").$strip>>;
667
+ }, import("zod/v4/core").$strip>;
668
+ };
669
+ };
670
+ listNonDefaultEndpointCosts: {
671
+ method: "get";
672
+ path: string;
673
+ responses: {
674
+ 200: import("zod").ZodObject<{
675
+ default_cost: import("zod").ZodNumber;
676
+ endpoint_costs: import("zod").ZodArray<import("zod").ZodObject<{
677
+ method: import("zod").ZodString;
678
+ path: import("zod").ZodString;
679
+ cost: import("zod").ZodNumber;
680
+ }, import("zod/v4/core").$strip>>;
681
+ }, import("zod/v4/core").$strip>;
682
+ };
683
+ metadata: {
684
+ [x: symbol]: boolean;
685
+ };
686
+ };
687
+ };
688
+ orders: {
689
+ getOrder: {
690
+ method: "get";
691
+ path: string;
692
+ params: import("zod").ZodObject<{
693
+ order_id: import("zod").ZodUUID;
694
+ }, import("zod/v4/core").$strip>;
695
+ responses: {
696
+ 200: import("zod").ZodObject<{
697
+ order: import("zod").ZodObject<{
698
+ order_id: import("zod").ZodUUID;
699
+ user_id: import("zod").ZodUUID;
700
+ client_order_id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
701
+ order_group_id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
702
+ subaccount_number: import("zod").ZodDefault<import("zod").ZodNumber>;
703
+ exchange_index: import("zod").ZodDefault<import("zod").ZodNumber>;
704
+ ticker: import("zod").ZodString;
705
+ type: import("zod").ZodEnum<{
706
+ limit: "limit";
707
+ market: "market";
708
+ }>;
709
+ outcome_side: import("zod").ZodEnum<{
710
+ yes: "yes";
711
+ no: "no";
712
+ }>;
713
+ book_side: import("zod").ZodEnum<{
714
+ bid: "bid";
715
+ ask: "ask";
716
+ }>;
717
+ status: import("zod").ZodEnum<{
718
+ resting: "resting";
719
+ canceled: "canceled";
720
+ executed: "executed";
721
+ }>;
722
+ yes_price_dollars: import("zod").ZodString;
723
+ no_price_dollars: import("zod").ZodString;
724
+ fill_count_fp: import("zod").ZodString;
725
+ remaining_count_fp: import("zod").ZodString;
726
+ initial_count_fp: import("zod").ZodString;
727
+ taker_fill_cost_dollars: import("zod").ZodString;
728
+ maker_fill_cost_dollars: import("zod").ZodString;
729
+ taker_fees_dollars: import("zod").ZodString;
730
+ maker_fees_dollars: import("zod").ZodString;
731
+ self_trade_prevention_type: import("zod").ZodEnum<{
732
+ taker_at_cross: "taker_at_cross";
733
+ maker: "maker";
734
+ }>;
735
+ cancel_order_on_pause: import("zod").ZodBoolean;
736
+ created_time: import("zod").ZodISODateTime;
737
+ last_update_time: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodISODateTime>>;
738
+ expiration_time: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodISODateTime>>;
739
+ }, import("zod/v4/core").$strip>;
740
+ }, import("zod/v4/core").$strip>;
741
+ };
742
+ };
743
+ createOrder: {
744
+ method: "post";
745
+ path: string;
746
+ body: import("zod").ZodObject<{
747
+ client_order_id: import("zod").ZodOptional<import("zod").ZodString>;
748
+ order_group_id: import("zod").ZodOptional<import("zod").ZodString>;
749
+ exchange_index: import("zod").ZodDefault<import("zod").ZodNumber>;
750
+ ticker: import("zod").ZodString;
751
+ side: import("zod").ZodEnum<{
752
+ bid: "bid";
753
+ ask: "ask";
754
+ }>;
755
+ count: import("zod").ZodString;
756
+ subaccount: import("zod").ZodDefault<import("zod").ZodNumber>;
757
+ price: import("zod").ZodString;
758
+ post_only: import("zod").ZodDefault<import("zod").ZodBoolean>;
759
+ reduce_only: import("zod").ZodDefault<import("zod").ZodBoolean>;
760
+ cancel_order_on_pause: import("zod").ZodBoolean;
761
+ self_trade_prevention_type: import("zod").ZodEnum<{
762
+ taker_at_cross: "taker_at_cross";
763
+ maker: "maker";
764
+ }>;
765
+ time_in_force: import("zod").ZodEnum<{
766
+ fill_or_kill: "fill_or_kill";
767
+ good_till_canceled: "good_till_canceled";
768
+ immediate_or_cancel: "immediate_or_cancel";
769
+ }>;
770
+ expiration_time: import("zod").ZodOptional<import("zod").ZodNumber>;
771
+ }, import("zod/v4/core").$strip>;
772
+ responses: {
773
+ 201: import("zod").ZodObject<{
774
+ order_id: import("zod").ZodUUID;
775
+ client_order_id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
776
+ fill_count: import("zod").ZodString;
777
+ remaining_count: import("zod").ZodString;
778
+ average_fill_price: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
779
+ average_fee_paid: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
780
+ ts_ms: import("zod").ZodNumber;
781
+ }, import("zod/v4/core").$strip>;
782
+ };
783
+ };
784
+ cancelOrderV1: {
785
+ method: "delete";
786
+ path: string;
787
+ params: import("zod").ZodObject<{
788
+ order_id: import("zod").ZodUUID;
789
+ }, import("zod/v4/core").$strip>;
790
+ query: import("zod").ZodPrefault<import("zod").ZodObject<{
791
+ subaccount: import("zod").ZodDefault<import("zod").ZodNumber>;
792
+ exchange_index: import("zod").ZodDefault<import("zod").ZodNumber>;
793
+ }, import("zod/v4/core").$strip>>;
794
+ responses: {
795
+ 200: import("zod").ZodObject<{
796
+ order: import("zod").ZodObject<{
797
+ order_id: import("zod").ZodUUID;
798
+ user_id: import("zod").ZodUUID;
799
+ client_order_id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
800
+ order_group_id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
801
+ subaccount_number: import("zod").ZodDefault<import("zod").ZodNumber>;
802
+ exchange_index: import("zod").ZodDefault<import("zod").ZodNumber>;
803
+ ticker: import("zod").ZodString;
804
+ type: import("zod").ZodEnum<{
805
+ limit: "limit";
806
+ market: "market";
807
+ }>;
808
+ outcome_side: import("zod").ZodEnum<{
809
+ yes: "yes";
810
+ no: "no";
811
+ }>;
812
+ book_side: import("zod").ZodEnum<{
813
+ bid: "bid";
814
+ ask: "ask";
815
+ }>;
816
+ status: import("zod").ZodEnum<{
817
+ resting: "resting";
818
+ canceled: "canceled";
819
+ executed: "executed";
820
+ }>;
821
+ yes_price_dollars: import("zod").ZodString;
822
+ no_price_dollars: import("zod").ZodString;
823
+ fill_count_fp: import("zod").ZodString;
824
+ remaining_count_fp: import("zod").ZodString;
825
+ initial_count_fp: import("zod").ZodString;
826
+ taker_fill_cost_dollars: import("zod").ZodString;
827
+ maker_fill_cost_dollars: import("zod").ZodString;
828
+ taker_fees_dollars: import("zod").ZodString;
829
+ maker_fees_dollars: import("zod").ZodString;
830
+ self_trade_prevention_type: import("zod").ZodEnum<{
831
+ taker_at_cross: "taker_at_cross";
832
+ maker: "maker";
833
+ }>;
834
+ cancel_order_on_pause: import("zod").ZodBoolean;
835
+ created_time: import("zod").ZodISODateTime;
836
+ last_update_time: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodISODateTime>>;
837
+ expiration_time: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodISODateTime>>;
838
+ }, import("zod/v4/core").$strip>;
839
+ reduced_by_fp: import("zod").ZodString;
840
+ }, import("zod/v4/core").$strip>;
841
+ };
842
+ };
843
+ cancelOrderV2: {
844
+ method: "delete";
845
+ path: string;
846
+ params: import("zod").ZodObject<{
847
+ order_id: import("zod").ZodUUID;
848
+ }, import("zod/v4/core").$strip>;
849
+ query: import("zod").ZodPrefault<import("zod").ZodObject<{
850
+ subaccount: import("zod").ZodDefault<import("zod").ZodNumber>;
851
+ exchange_index: import("zod").ZodDefault<import("zod").ZodNumber>;
852
+ }, import("zod/v4/core").$strip>>;
853
+ responses: {
854
+ 200: import("zod").ZodObject<{
855
+ order_id: import("zod").ZodUUID;
856
+ client_order_id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
857
+ reduced_by: import("zod").ZodString;
858
+ ts_ms: import("zod").ZodNumber;
859
+ }, import("zod/v4/core").$strip>;
860
+ };
861
+ };
862
+ getOrderQueuePosition: {
863
+ method: "get";
864
+ path: string;
865
+ params: import("zod").ZodObject<{
866
+ order_id: import("zod").ZodUUID;
867
+ }, import("zod/v4/core").$strip>;
868
+ responses: {
869
+ 200: import("zod").ZodObject<{
870
+ queue_position_fp: import("zod").ZodString;
871
+ }, import("zod/v4/core").$strip>;
872
+ };
873
+ };
874
+ };
875
+ };
876
+ //#endregion
877
+ //#region src/api/client.d.ts
878
+ type ApiClientConfig = {
879
+ environment?: KalshiEnvironment;
880
+ credentialsProvider: ICredentialsProvider;
881
+ checkCostsInterval?: number;
882
+ };
883
+ type ApiClientConfigType = ApiClientConfig$1 & ApiClientConfig;
884
+ declare class ApiClient extends ApiClient$1<typeof apiRouter, ApiClientConfigType> {
885
+ /**
886
+ * @param {ApiClientConfig} config
887
+ */
888
+ constructor(config: ApiClientConfig);
889
+ /**
890
+ * @template {Route} TRoute
891
+ * @param {TRoute} route
892
+ * @param {ApiRequestParams<TRoute>} params
893
+ * @param {ApiCallOptions} options
894
+ * @return {Promise<ApiResponse<TRoute>>}
895
+ */
896
+ /**
897
+ * @param {"force"} force
898
+ * @return {Promise<void>}
899
+ * @private
900
+ */
901
+ /**
902
+ * @param {ApiRawRequest} req
903
+ * @return {ApiRawRequest}
904
+ * @protected
905
+ */
906
+ protected onBeforeRequest(req: ApiRawRequest): ApiRawRequest;
907
+ }
908
+ //#endregion
909
+ export { Account$AccountGrant, Account$AccountTier, Account$Subaccount, ApiClient, type ApiClientConfig, Http$ErrorMessage, type ICredentialsProvider, type IRequestSigner, InMemoryCredentialsProvider, type InMemoryCredentialsProviderOptions, Orders$ClientOrderId, Orders$CreateOrderDto, Orders$OrderDetailed, Orders$OrderStatus, Orders$OrderWs, Orders$TimeInForce, Primitives$BookSide, Primitives$FixedPoint, Primitives$OrderAction, Primitives$OrderSide, Primitives$RateLimitBucketMeta, RequestSigner, type RequestSignerOptions, type SignatureParameters, type SubscriptionOptions, WS_KALSHI_ERRORS, WS_KALSHI_SERVER_ERRORS, WsAnyMessage, WsClient, type WsClientOptions, WsClosedByUserError, WsClosedError, WsErrorMessage, WsKalshiError, WsOkMessage, WsSubscribedMessage, WsUserOrderMessage, account$accountGrantSchema, account$accountTierSchema, account$subaccountSchema, http$errorMessageSchema, orders$OrderType, orders$SelfTradePreventionType, orders$clientOrderIdSchema, orders$createOrderDtoSchema, orders$orderDetailedSchema, orders$orderStatusSchema, orders$orderTypeSchema, orders$orderWsSchema, orders$selfTradePreventionTypeSchema, orders$timeInForceSchema, primitives$bookSideSchema, primitives$fixedPointSchema, primitives$orderActionSchema, primitives$orderSideSchema, primitives$rateLimitBucketMetaSchema, wsAnyMessageSchema, wsErrorMessageSchema, wsOkMessageSchema, wsSubscribedMessageSchema, wsUserOrderMessageSchema };