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
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
amendSpotOrder()
amendSpotOrder(params: WSAPIAmendSpotOrderParams, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPIAmendSpotOrderResult, "amend_order">>;Amend an existing order
Parameters
| Parameter | Type |
|---|---|
params | WSAPIAmendSpotOrderParams |
wsKey? | keyof WSAPIWsKeyTopicMap |
Returns
Promise<WSAPISpotResponse<WSAPIAmendSpotOrderResult, "amend_order">>
batchCancelSpotOrders()
batchCancelSpotOrders(params: WSAPIBatchCancelSpotOrdersParams, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPIBatchCancelSpotOrdersResult, "batch_cancel">>;Cancel multiple orders in a single batch (2-50 orders)
Parameters
| Parameter | Type |
|---|---|
params | WSAPIBatchCancelSpotOrdersParams |
wsKey? | keyof WSAPIWsKeyTopicMap |
Returns
Promise<WSAPISpotResponse<WSAPIBatchCancelSpotOrdersResult, "batch_cancel">>
batchSubmitSpotOrders()
batchSubmitSpotOrders(params: WSAPIBatchAddSpotOrdersParams, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPIBatchAddSpotOrdersResult[], "batch_add">>;Add multiple orders in a single batch (2-15 orders)
Parameters
| Parameter | Type |
|---|---|
params | WSAPIBatchAddSpotOrdersParams |
wsKey? | keyof WSAPIWsKeyTopicMap |
Returns
Promise<WSAPISpotResponse<WSAPIBatchAddSpotOrdersResult[], "batch_add">>
cancelAllSpotOrders()
cancelAllSpotOrders(wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPICancelAllSpotOrdersResult, "cancel_all">>;Cancel all open orders
Parameters
| Parameter | Type |
|---|---|
wsKey? | keyof WSAPIWsKeyTopicMap |
Returns
Promise<WSAPISpotResponse<WSAPICancelAllSpotOrdersResult, "cancel_all">>
cancelAllSpotOrdersAfter()
cancelAllSpotOrdersAfter(params: WSAPICancelAllSpotOrdersAfterParams, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPICancelAllSpotOrdersAfterResult, "cancel_all_orders_after">>;Cancel all orders after a timeout (Dead Man's Switch)
Parameters
| Parameter | Type |
|---|---|
params | WSAPICancelAllSpotOrdersAfterParams |
wsKey? | keyof WSAPIWsKeyTopicMap |
Returns
Promise<WSAPISpotResponse<WSAPICancelAllSpotOrdersAfterResult, "cancel_all_orders_after">>
cancelSpotOrder()
cancelSpotOrder(params: WSAPICancelSpotOrderParams, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPICancelSpotOrderResult, "cancel_order">>;Cancel one or more orders
Parameters
| Parameter | Type |
|---|---|
params | WSAPICancelSpotOrderParams |
wsKey? | keyof WSAPIWsKeyTopicMap |
Returns
Promise<WSAPISpotResponse<WSAPICancelSpotOrderResult, "cancel_order">>
connectWSAPI()
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
| Parameter | Type |
|---|---|
wsKey | keyof WSAPIWsKeyTopicMap |
Returns
Promise<unknown>
editSpotOrder()
editSpotOrder(params: WSAPIEditSpotOrderParams, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPIEditSpotOrderResult, "edit_order">>;Edit an existing order (legacy method, use amendSpotOrder instead)
Parameters
| Parameter | Type |
|---|---|
params | WSAPIEditSpotOrderParams |
wsKey? | keyof WSAPIWsKeyTopicMap |
Returns
Promise<WSAPISpotResponse<WSAPIEditSpotOrderResult, "edit_order">>
Deprecated
Use amendSpotOrder for better performance and features
getWSClient()
getWSClient(): WebsocketClient;Returns
submitSpotOrder()
submitSpotOrder(params: Omit<WSAPIAddSpotOrderParams, "token" | "req_id">, wsKey?: keyof WSAPIWsKeyTopicMap): Promise<WSAPISpotResponse<WSAPIAddSpotOrderResult, "add_order">>;Add a spot order
Parameters
| Parameter | Type |
|---|---|
params | Omit<WSAPIAddSpotOrderParams, "token" | "req_id"> |
wsKey? | keyof WSAPIWsKeyTopicMap |
Returns
Promise<WSAPISpotResponse<WSAPIAddSpotOrderResult, "add_order">>