Skip to content

Clients ​

REST clients return promises. WebsocketClient delivers subscriptions through event listeners, while WebsocketAPIClient exposes awaitable Spot WebSocket operations.

ClientPurpose
SpotClientSpot market data, balances, orders and account operations over REST.
DerivativesClientFutures market data, account queries and trading over REST.
WebsocketClientPublic and private Spot and Futures subscriptions.
WebsocketAPIClientAwaitable Spot WebSocket API requests.

Start with SpotClient for Spot endpoints or DerivativesClient for Futures. These APIs use different credentials, symbols and response formats.

Unified public WebSocket support is in development. The current SDK uses WebsocketClient for Futures subscriptions and WebsocketAPIClient for Spot order entry. Kraken’s existing Futures feed remains available until 1 March 2027.

REST requests ​

ts
import { SpotClient } from '@siebly/kraken-api';

async function main() {
  const client = new SpotClient();
  const response = await client.getTicker({ pair: 'XBTUSD' });

  for (const [pair, ticker] of Object.entries(response.result)) {
    console.log(`${pair} last price: ${ticker.c[0]}`);
  }
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

WebSocket subscriptions ​

Register event listeners before calling subscribe(). Choose the connection with WS_KEY_MAP, such as spotPublicV2 for public Spot v2 data. See the complete subscription example.

WebSocket requests ​

Use WebsocketAPIClient when a supported Spot operation should return a promise instead of being handled as a stream.

Use await and try/catch just as you would with a REST API call. The SDK matches responses to requests and manages the WebSocket connection for you. Requests over a persistent WebSocket can offer lower overhead and latency, depending on the exchange, network and workload.

A lost connection can reject an in-flight request even if the exchange processed it; reconcile uncertain outcomes before retrying an order.

Reference index · API reference

Built by Siebly. Open source SDKs for exchange APIs.