Skip to content

Public market data (REST) ​

Public Spot and Futures endpoints need no API credentials.

Spot order book ​

Save this plain JavaScript example as order-book.mjs and run node order-book.mjs:

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

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

  for (const [pair, book] of Object.entries(response.result)) {
    console.log(pair, { bids: book.bids, asks: book.asks });
  }
}

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

The response contains result, keyed by Kraken's returned pair name. Each bids or asks entry contains price, volume and timestamp. count: 10 requests ten levels per side; the available book may contain fewer.

Spot REST accepts aliases such as XBTUSD. Spot WebSocket v2 uses symbols such as BTC/USD. Use getAssetPairs() for REST pair metadata and the instrument channel for WebSocket v2 symbols.

Futures tickers ​

Save this as futures.mjs and run node futures.mjs:

js
import { DerivativesClient } from '@siebly/kraken-api';

async function main() {
  const client = new DerivativesClient();
  const response = await client.getTickers();
  console.log(response.tickers);
}

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

Futures responses have a different structure: getTickers() returns tickers directly on the response, not under Spot's result object. Use the returned contract symbols with the corresponding Futures methods.

Streaming data ​

Use WebSocket subscriptions for updates instead of repeatedly polling a ticker. To maintain a local order book, apply the channel's snapshot, update and checksum rules.

SpotClient reference · DerivativesClient reference

Built by Siebly. Open source SDKs for exchange APIs.