Class: WebsocketAPIClient
Promise-based wrapper for KuCoin WebSocket API order commands. Connections and authentication are handled as needed. Use getWSClient() for lifecycle events and shutdown. This release has no supported testnet constructor option; commands use live services.
Constructors
Constructor
new WebsocketAPIClient(options?: WSClientConfigurableOptions & Partial<WSAPIClientConfigurableOptions>, logger?: object): WebsocketAPIClient;Parameters
| Parameter | Type |
|---|---|
options? | WSClientConfigurableOptions & Partial<WSAPIClientConfigurableOptions> |
logger? | { error: (...params: any) => void; info: (...params: any) => void; trace: (..._params: any) => void; } |
logger.error? | (...params: any) => void |
logger.info? | (...params: any) => void |
logger.trace? | (..._params: any) => void |
Returns
WebsocketAPIClient
Methods
amendFuturesOrder()
amendFuturesOrder(params: AmendOrderRequestUTA, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<AmendOrderResponseUTA,
| "ping"
| "spot.order"
| "spot.modify"
| "spot.cancel"
| "spot.sync_order"
| "spot.sync_cancel"
| "margin.order"
| "margin.cancel"
| "futures.order"
| "futures.cancel"
| "futures.multi_order"
| "futures.multi_cancel"
| "uta.amend">>;Amend a UTA futures order. Futures only (op: uta.amend).
Parameters
| Parameter | Type |
|---|---|
params | AmendOrderRequestUTA |
wsKey? | WSAPIWsKey |
Returns
Promise<WSAPIResponse<AmendOrderResponseUTA, | "ping" | "spot.order" | "spot.modify" | "spot.cancel" | "spot.sync_order" | "spot.sync_cancel" | "margin.order" | "margin.cancel" | "futures.order" | "futures.cancel" | "futures.multi_order" | "futures.multi_cancel" | "uta.amend">>
cancelFuturesOrder()
cancelFuturesOrder(params:
| {
orderId: string;
}
| {
clientOid: string;
symbol: string;
}, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<
| {
cancelledOrderIds: string[];
}
| {
clientOid: string;
},
| "ping"
| "spot.order"
| "spot.modify"
| "spot.cancel"
| "spot.sync_order"
| "spot.sync_cancel"
| "margin.order"
| "margin.cancel"
| "futures.order"
| "futures.cancel"
| "futures.multi_order"
| "futures.multi_cancel"
| "uta.amend">>;Cancel a futures order
Parameters
| Parameter | Type |
|---|---|
params | | { orderId: string; } | { clientOid: string; symbol: string; } |
wsKey? | WSAPIWsKey |
Returns
Promise<WSAPIResponse< | { cancelledOrderIds: string[]; } | { clientOid: string; }, | "ping" | "spot.order" | "spot.modify" | "spot.cancel" | "spot.sync_order" | "spot.sync_cancel" | "margin.order" | "margin.cancel" | "futures.order" | "futures.cancel" | "futures.multi_order" | "futures.multi_cancel" | "uta.amend">>
cancelMarginOrder()
cancelMarginOrder(params: WSAPICancelOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<WSAPIOrderResponse,
| "ping"
| "spot.order"
| "spot.modify"
| "spot.cancel"
| "spot.sync_order"
| "spot.sync_cancel"
| "margin.order"
| "margin.cancel"
| "futures.order"
| "futures.cancel"
| "futures.multi_order"
| "futures.multi_cancel"
| "uta.amend">>;Cancel a margin order
Parameters
| Parameter | Type |
|---|---|
params | WSAPICancelOrderRequest |
wsKey? | WSAPIWsKey |
Returns
Promise<WSAPIResponse<WSAPIOrderResponse, | "ping" | "spot.order" | "spot.modify" | "spot.cancel" | "spot.sync_order" | "spot.sync_cancel" | "margin.order" | "margin.cancel" | "futures.order" | "futures.cancel" | "futures.multi_order" | "futures.multi_cancel" | "uta.amend">>
cancelMultipleFuturesOrders()
cancelMultipleFuturesOrders(params: BatchCancelOrdersRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<BatchCancelOrderResult[],
| "ping"
| "spot.order"
| "spot.modify"
| "spot.cancel"
| "spot.sync_order"
| "spot.sync_cancel"
| "margin.order"
| "margin.cancel"
| "futures.order"
| "futures.cancel"
| "futures.multi_order"
| "futures.multi_cancel"
| "uta.amend">>;Cancel multiple futures orders
Parameters
| Parameter | Type |
|---|---|
params | BatchCancelOrdersRequest |
wsKey? | WSAPIWsKey |
Returns
Promise<WSAPIResponse<BatchCancelOrderResult[], | "ping" | "spot.order" | "spot.modify" | "spot.cancel" | "spot.sync_order" | "spot.sync_cancel" | "margin.order" | "margin.cancel" | "futures.order" | "futures.cancel" | "futures.multi_order" | "futures.multi_cancel" | "uta.amend">>
cancelSpotOrder()
cancelSpotOrder(params: WSAPICancelOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<WSAPIOrderResponse,
| "ping"
| "spot.order"
| "spot.modify"
| "spot.cancel"
| "spot.sync_order"
| "spot.sync_cancel"
| "margin.order"
| "margin.cancel"
| "futures.order"
| "futures.cancel"
| "futures.multi_order"
| "futures.multi_cancel"
| "uta.amend">>;Cancel a spot order
Parameters
| Parameter | Type |
|---|---|
params | WSAPICancelOrderRequest |
wsKey? | WSAPIWsKey |
Returns
Promise<WSAPIResponse<WSAPIOrderResponse, | "ping" | "spot.order" | "spot.modify" | "spot.cancel" | "spot.sync_order" | "spot.sync_cancel" | "margin.order" | "margin.cancel" | "futures.order" | "futures.cancel" | "futures.multi_order" | "futures.multi_cancel" | "uta.amend">>
See
cancelSyncSpotOrder()
cancelSyncSpotOrder(params: WSAPICancelOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<SyncCancelHFOrderResponse,
| "ping"
| "spot.order"
| "spot.modify"
| "spot.cancel"
| "spot.sync_order"
| "spot.sync_cancel"
| "margin.order"
| "margin.cancel"
| "futures.order"
| "futures.cancel"
| "futures.multi_order"
| "futures.multi_cancel"
| "uta.amend">>;Cancel a sync spot order
Parameters
| Parameter | Type |
|---|---|
params | WSAPICancelOrderRequest |
wsKey? | WSAPIWsKey |
Returns
Promise<WSAPIResponse<SyncCancelHFOrderResponse, | "ping" | "spot.order" | "spot.modify" | "spot.cancel" | "spot.sync_order" | "spot.sync_cancel" | "margin.order" | "margin.cancel" | "futures.order" | "futures.cancel" | "futures.multi_order" | "futures.multi_cancel" | "uta.amend">>
connectWSAPI()
connectWSAPI(wsKey: WSAPIWsKey): Promise<unknown>;Private methods for handling some of the convenience/automation provided by the WS API Client
Parameters
| Parameter | Type |
|---|---|
wsKey | WSAPIWsKey |
Returns
Promise<unknown>
getWSClient()
getWSClient(): WebsocketClient;Returns
See
modifySpotOrder()
modifySpotOrder(params: ModifyHFOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<{
clientOid: string;
newOrderId: string;
},
| "ping"
| "spot.order"
| "spot.modify"
| "spot.cancel"
| "spot.sync_order"
| "spot.sync_cancel"
| "margin.order"
| "margin.cancel"
| "futures.order"
| "futures.cancel"
| "futures.multi_order"
| "futures.multi_cancel"
| "uta.amend">>;Modify a spot order
Parameters
| Parameter | Type |
|---|---|
params | ModifyHFOrderRequest |
wsKey? | WSAPIWsKey |
Returns
Promise<WSAPIResponse<{ clientOid: string; newOrderId: string; }, | "ping" | "spot.order" | "spot.modify" | "spot.cancel" | "spot.sync_order" | "spot.sync_cancel" | "margin.order" | "margin.cancel" | "futures.order" | "futures.cancel" | "futures.multi_order" | "futures.multi_cancel" | "uta.amend">>
See
submitFuturesOrder()
submitFuturesOrder(params: Order, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<WSAPIOrderResponse,
| "ping"
| "spot.order"
| "spot.modify"
| "spot.cancel"
| "spot.sync_order"
| "spot.sync_cancel"
| "margin.order"
| "margin.cancel"
| "futures.order"
| "futures.cancel"
| "futures.multi_order"
| "futures.multi_cancel"
| "uta.amend">>;Submit a futures order
Parameters
| Parameter | Type |
|---|---|
params | Order |
wsKey? | WSAPIWsKey |
Returns
Promise<WSAPIResponse<WSAPIOrderResponse, | "ping" | "spot.order" | "spot.modify" | "spot.cancel" | "spot.sync_order" | "spot.sync_cancel" | "margin.order" | "margin.cancel" | "futures.order" | "futures.cancel" | "futures.multi_order" | "futures.multi_cancel" | "uta.amend">>
submitMarginOrder()
submitMarginOrder(params: SubmitHFMarginOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<MarginSubmitOrderV3Response,
| "ping"
| "spot.order"
| "spot.modify"
| "spot.cancel"
| "spot.sync_order"
| "spot.sync_cancel"
| "margin.order"
| "margin.cancel"
| "futures.order"
| "futures.cancel"
| "futures.multi_order"
| "futures.multi_cancel"
| "uta.amend">>;Submit a margin order
Parameters
| Parameter | Type |
|---|---|
params | SubmitHFMarginOrderRequest |
wsKey? | WSAPIWsKey |
Returns
Promise<WSAPIResponse<MarginSubmitOrderV3Response, | "ping" | "spot.order" | "spot.modify" | "spot.cancel" | "spot.sync_order" | "spot.sync_cancel" | "margin.order" | "margin.cancel" | "futures.order" | "futures.cancel" | "futures.multi_order" | "futures.multi_cancel" | "uta.amend">>
submitMultipleFuturesOrders()
submitMultipleFuturesOrders(params: Order[], wsKey?: WSAPIWsKey): Promise<WSAPIResponse<SubmitMultipleOrdersFuturesResponse[],
| "ping"
| "spot.order"
| "spot.modify"
| "spot.cancel"
| "spot.sync_order"
| "spot.sync_cancel"
| "margin.order"
| "margin.cancel"
| "futures.order"
| "futures.cancel"
| "futures.multi_order"
| "futures.multi_cancel"
| "uta.amend">>;Submit multiple futures orders
Parameters
| Parameter | Type |
|---|---|
params | Order[] |
wsKey? | WSAPIWsKey |
Returns
Promise<WSAPIResponse<SubmitMultipleOrdersFuturesResponse[], | "ping" | "spot.order" | "spot.modify" | "spot.cancel" | "spot.sync_order" | "spot.sync_cancel" | "margin.order" | "margin.cancel" | "futures.order" | "futures.cancel" | "futures.multi_order" | "futures.multi_cancel" | "uta.amend">>
submitNewSpotOrder()
submitNewSpotOrder(params: SubmitHFOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<WSAPIOrderResponse,
| "ping"
| "spot.order"
| "spot.modify"
| "spot.cancel"
| "spot.sync_order"
| "spot.sync_cancel"
| "margin.order"
| "margin.cancel"
| "futures.order"
| "futures.cancel"
| "futures.multi_order"
| "futures.multi_cancel"
| "uta.amend">>;Submit a spot order
Parameters
| Parameter | Type |
|---|---|
params | SubmitHFOrderRequest |
wsKey? | WSAPIWsKey |
Returns
Promise<WSAPIResponse<WSAPIOrderResponse, | "ping" | "spot.order" | "spot.modify" | "spot.cancel" | "spot.sync_order" | "spot.sync_cancel" | "margin.order" | "margin.cancel" | "futures.order" | "futures.cancel" | "futures.multi_order" | "futures.multi_cancel" | "uta.amend">>
See
submitSyncSpotOrder()
submitSyncSpotOrder(params: SubmitHFOrderRequest, wsKey?: WSAPIWsKey): Promise<WSAPIResponse<SubmitHFOrderSyncResponse,
| "ping"
| "spot.order"
| "spot.modify"
| "spot.cancel"
| "spot.sync_order"
| "spot.sync_cancel"
| "margin.order"
| "margin.cancel"
| "futures.order"
| "futures.cancel"
| "futures.multi_order"
| "futures.multi_cancel"
| "uta.amend">>;Submit a sync spot order
Parameters
| Parameter | Type |
|---|---|
params | SubmitHFOrderRequest |
wsKey? | WSAPIWsKey |
Returns
Promise<WSAPIResponse<SubmitHFOrderSyncResponse, | "ping" | "spot.order" | "spot.modify" | "spot.cancel" | "spot.sync_order" | "spot.sync_cancel" | "margin.order" | "margin.cancel" | "futures.order" | "futures.cancel" | "futures.multi_order" | "futures.multi_cancel" | "uta.amend">>