Skip to content

Class: WebsocketAPIClient ​

Promise-based wrapper around WebsocketClient for Kraken Spot trading requests. Trading methods default to spotPrivateV2; pass spotBetaPrivateV2 as wsKey to select the supported beta endpoint. Use getWSClient() to access the underlying client, or call its sendWSAPIRequest() directly.

Constructors ​

Constructor ​

ts
new WebsocketAPIClient(options?: WSClientConfigurableOptions & Partial<WSAPIClientConfigurableOptions>, logger?: object): WebsocketAPIClient;

Parameters ​

ParameterType
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 ​

amendSpotOrder() ​

ts
amendSpotOrder(params: WSAPIAmendSpotOrderParams, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPIAmendSpotOrderResult, "amend_order">>;

Amend an existing order

Parameters ​

ParameterType
paramsWSAPIAmendSpotOrderParams
wsKey?keyof WSAPIWsKeyTopicMap

Returns ​

Promise<WSAPISpotResponse<WSAPIAmendSpotOrderResult, "amend_order">>


batchCancelSpotOrders() ​

ts
batchCancelSpotOrders(params: WSAPIBatchCancelSpotOrdersParams, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPIBatchCancelSpotOrdersResult, "batch_cancel">>;

Cancel multiple orders in a single batch (2-50 orders)

Parameters ​

ParameterType
paramsWSAPIBatchCancelSpotOrdersParams
wsKey?keyof WSAPIWsKeyTopicMap

Returns ​

Promise<WSAPISpotResponse<WSAPIBatchCancelSpotOrdersResult, "batch_cancel">>


batchSubmitSpotOrders() ​

ts
batchSubmitSpotOrders(params: WSAPIBatchAddSpotOrdersParams, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPIBatchAddSpotOrdersResult[], "batch_add">>;

Add multiple orders in a single batch (2-15 orders)

Parameters ​

ParameterType
paramsWSAPIBatchAddSpotOrdersParams
wsKey?keyof WSAPIWsKeyTopicMap

Returns ​

Promise<WSAPISpotResponse<WSAPIBatchAddSpotOrdersResult[], "batch_add">>


cancelAllSpotOrders() ​

ts
cancelAllSpotOrders(wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPICancelAllSpotOrdersResult, "cancel_all">>;

Cancel all open orders

Parameters ​

ParameterType
wsKey?keyof WSAPIWsKeyTopicMap

Returns ​

Promise<WSAPISpotResponse<WSAPICancelAllSpotOrdersResult, "cancel_all">>


cancelAllSpotOrdersAfter() ​

ts
cancelAllSpotOrdersAfter(params: WSAPICancelAllSpotOrdersAfterParams, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPICancelAllSpotOrdersAfterResult, "cancel_all_orders_after">>;

Cancel all orders after a timeout (Dead Man's Switch)

Parameters ​

ParameterType
paramsWSAPICancelAllSpotOrdersAfterParams
wsKey?keyof WSAPIWsKeyTopicMap

Returns ​

Promise<WSAPISpotResponse<WSAPICancelAllSpotOrdersAfterResult, "cancel_all_orders_after">>


cancelSpotOrder() ​

ts
cancelSpotOrder(params: WSAPICancelSpotOrderParams, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPICancelSpotOrderResult, "cancel_order">>;

Cancel one or more orders

Parameters ​

ParameterType
paramsWSAPICancelSpotOrderParams
wsKey?keyof WSAPIWsKeyTopicMap

Returns ​

Promise<WSAPISpotResponse<WSAPICancelSpotOrderResult, "cancel_order">>


connectWSAPI() ​

ts
connectWSAPI(wsKey: keyof WSAPIWsKeyTopicMap): Promise<unknown>;

Open the selected Spot WebSocket API connection before sending requests. Spot authentication is included in each request; this method does not confirm credentials with a login exchange.

Parameters ​

ParameterType
wsKeykeyof WSAPIWsKeyTopicMap

Returns ​

Promise<unknown>


editSpotOrder() ​

ts
editSpotOrder(params: WSAPIEditSpotOrderParams, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPIEditSpotOrderResult, "edit_order">>;

Edit an existing order (legacy method, use amendSpotOrder instead)

Parameters ​

ParameterType
paramsWSAPIEditSpotOrderParams
wsKey?keyof WSAPIWsKeyTopicMap

Returns ​

Promise<WSAPISpotResponse<WSAPIEditSpotOrderResult, "edit_order">>

Deprecated ​

Use amendSpotOrder for better performance and features


getWSClient() ​

ts
getWSClient(): WebsocketClient;

Returns ​

WebsocketClient


submitSpotOrder() ​

ts
submitSpotOrder(params: Omit<WSAPIAddSpotOrderParams, "token" | "req_id">, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPIAddSpotOrderResult, "add_order">>;

Add a spot order

Parameters ​

ParameterType
paramsOmit<WSAPIAddSpotOrderParams, "token" | "req_id">
wsKey?keyof WSAPIWsKeyTopicMap

Returns ​

Promise<WSAPISpotResponse<WSAPIAddSpotOrderResult, "add_order">>

Built by Siebly. Open source SDKs for exchange APIs.