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