kucoin-api
Version:
Complete & robust Node.js SDK for Kucoin's REST APIs and WebSockets, with TypeScript & strong end to end tests.
124 lines (123 loc) • 4.81 kB
TypeScript
import { DefaultLogger } from './lib/websocket/logger.js';
import { WSAPIWsKey } from './lib/websocket/websocket-util.js';
import { BatchCancelOrdersRequest, Order } from './types/request/futures.types.js';
import { SubmitHFMarginOrderRequest } from './types/request/spot-margin-trading.js';
import { ModifyHFOrderRequest, SubmitHFOrderRequest } from './types/request/spot-trading.js';
import { BatchCancelOrderResult, SubmitMultipleOrdersFuturesResponse } from './types/response/futures.types.js';
import { MarginSubmitOrderV3Response } from './types/response/spot-margin-trading.js';
import { SubmitHFOrderSyncResponse, SyncCancelHFOrderResponse } from './types/response/spot-trading.js';
import { WSAPICancelOrderRequest, WSAPIOrderResponse, WSAPIResponse } from './types/websockets/ws-api.js';
import { WSClientConfigurableOptions } from './types/websockets/ws-general.js';
import { WebsocketClient } from './WebsocketClient.js';
/**
* Configurable options specific to only the REST-like WebsocketAPIClient
*/
export interface WSAPIClientConfigurableOptions {
/**
* Default: true
*
* Attach default event listeners, which will console log any high level
* events (opened/reconnecting/reconnected/etc).
*
* If you disable this, you should set your own event listeners
* on the embedded WS Client `wsApiClient.getWSClient().on(....)`.
*/
attachEventListeners: boolean;
}
/**
* This is a minimal Websocket API wrapper around the WebsocketClient.
*
* Some methods support passing in a custom "wsKey". This is a reference to which WS connection should
* be used to transmit that message. This is only useful if you wish to use an alternative wss
* domain that is supported by the SDK.
*
* Note: To use testnet, don't set the wsKey - use `testnet: true` in
* the constructor instead.
*
* Note: You can also directly use the sendWSAPIRequest() method to make WS API calls, but some
* may find the below methods slightly more intuitive.
*
* Refer to the WS API promises example for a more detailed example on using sendWSAPIRequest() directly:
* https://github.com/tiagosiebler/binance/blob/master/examples/WebSockets/ws-api-raw-promises.ts#L108
*/
export declare class WebsocketAPIClient {
private wsClient;
private options;
constructor(options?: WSClientConfigurableOptions & Partial<WSAPIClientConfigurableOptions>, logger?: DefaultLogger);
getWSClient(): WebsocketClient;
/**
* Submit a spot order
*/
submitNewSpotOrder(params: SubmitHFOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<WSAPIOrderResponse>>;
/**
* Modify a spot order
*/
modifySpotOrder(params: ModifyHFOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<{
newOrderId: string;
clientOid: string;
}>>;
/**
* Cancel a spot order
*/
cancelSpotOrder(params: WSAPICancelOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<WSAPIOrderResponse>>;
/**
* Submit a sync spot order
*/
submitSyncSpotOrder(params: SubmitHFOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<SubmitHFOrderSyncResponse>>;
/**
* Cancel a sync spot order
*/
cancelSyncSpotOrder(params: WSAPICancelOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<SyncCancelHFOrderResponse>>;
/**
* Submit a margin order
*/
submitMarginOrder(params: SubmitHFMarginOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<MarginSubmitOrderV3Response>>;
/**
* Cancel a margin order
*/
cancelMarginOrder(params: WSAPICancelOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<WSAPIOrderResponse>>;
/**
* Submit a futures order
*/
submitFuturesOrder(params: Order, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<WSAPIOrderResponse>>;
/**
* Cancel a futures order
*/
cancelFuturesOrder(params: {
orderId: string;
} | {
clientOid: string;
symbol: string;
}, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<{
cancelledOrderIds: string[];
} | {
clientOid: string;
}>>;
/**
* Submit multiple futures orders
*/
submitMultipleFuturesOrders(params: Order[], wsKey?: WSAPIWsKey): Promise<WSAPIResponse<SubmitMultipleOrdersFuturesResponse[]>>;
/**
* Cancel multiple futures orders
*/
cancelMultipleFuturesOrders(params: BatchCancelOrdersRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<BatchCancelOrderResult[]>>;
/**
*
*
*
*
*
*
*
* Private methods for handling some of the convenience/automation provided by the WS API Client
*
*
*
*
*
*
*
*/
connectWSAPI(wsKey: WSAPIWsKey): Promise<unknown>;
private setupDefaultEventListeners;
}