If you search for a Kraken SDK on npm, the first results are easy to mix up. The unscoped kraken-api package is a different, now-deprecated client. The kraken package is an image optimiser from kraken.io, not the exchange. This guide shows which package to install, then walks through a first request with @siebly/kraken-api, the open-source Node.js and TypeScript SDK we maintain at Siebly, in both JavaScript and TypeScript.
It is a getting-started note for the npm package itself. For a full tour of Spot, Futures and WebSocket commands, use the Kraken JavaScript tutorial and the Kraken JavaScript SDK page.
Which npm package is the Kraken SDK?
Kraken does not publish an official npm package for its exchange API. Several similarly named packages exist, and they are not interchangeable:
| Package | What it is |
|---|---|
@siebly/kraken-api |
Maintained TypeScript SDK for Kraken Spot and Futures REST APIs and WebSockets. This is the one to install. |
kraken-api (unscoped) |
A different Node client. Its own README now marks it as deprecated, and the npm listing points to that notice. Last published in August 2024. |
kraken |
The kraken.io image optimiser. It has nothing to do with the Kraken exchange. |
The SDK README calls this out directly: install the scoped package, because unscoped kraken-api is not this SDK. The scoped package is at version 1.1.10 at the time of writing, ships typings, and supports both ESM and CommonJS.
Install @siebly/kraken-api
In a Node.js project:
npm install @siebly/kraken-api
That is the only package name you need. If a snippet you copied uses require('kraken-api') or npm install kraken-api without the @siebly/ scope, it is for the other client and will not give you SpotClient or the typings below.
A first public request in JavaScript
Public Spot endpoints do not need API keys. This example uses ESM, so you can save it as rest-public.mjs and run it with node rest-public.mjs:
import { SpotClient } from '@siebly/kraken-api';
const client = new SpotClient();
async function main() {
const serverTime = await client.getServerTime();
const systemStatus = await client.getSystemStatus();
const ticker = await client.getTicker({ pair: 'XBTUSD' });
const orderBook = await client.getOrderBook({ pair: 'XBTUSD', count: 10 });
console.log({ serverTime, systemStatus, ticker, orderBook });
}
main().catch(console.error);
In a CommonJS file, change only the import:
const { SpotClient } = require('@siebly/kraken-api');
Successful Kraken responses keep the usual envelope: an error array, which is empty on success, and a result object with the data. getServerTime() returns result.unixtime (Unix seconds) and result.rfc1123 (a readable timestamp). Ticker and order-book results are keyed by the pair name Kraken returns, which may be XXBTZUSD even though you requested XBTUSD. Book levels include price, quantity and a timestamp. The values themselves change on every run, so check those fields rather than a fixed fixture.
The same request in TypeScript
The package is TypeScript-first and publishes declaration files, so the same clients work in a .ts file with typed requests and responses. No extra @types package is required:
import { SpotClient } from '@siebly/kraken-api';
const client = new SpotClient();
async function main(): Promise<void> {
const ticker = await client.getTicker({ pair: 'XBTUSD' });
console.log(ticker);
}
main().catch((err: unknown) => {
console.error(err);
});
Your editor should complete method names and parameter fields such as pair and count. If typings are missing, you almost certainly installed the unscoped package by mistake.
Private REST calls, and Spot versus Futures
For account data you pass a Spot API key and secret into SpotClient. Create those keys in Kraken’s API key settings, store them in environment variables, and never commit them:
import { SpotClient } from '@siebly/kraken-api';
const client = new SpotClient({
apiKey: process.env.KRAKEN_API_KEY,
apiSecret: process.env.KRAKEN_API_SECRET,
});
client
.getAccountBalance()
.then((balance) => {
console.log('Account Balance: ', balance);
})
.catch((err) => {
console.error('Error: ', err);
});
Spot and Futures are different API contracts, with different credentials and a different client. Use DerivativesClient for Futures, not SpotClient. The differences are covered in Kraken Spot and Futures use different API contracts. If a signed Spot request fails with EAPI:Invalid nonce, the checklist is in Kraken API EAPI:Invalid nonce in Node.js.
Public WebSocket streams
For live tickers and order books, WebsocketClient opens the stream, sends heartbeats, and resubscribes after a reconnect, which a raw ws socket leaves to you. API keys are not required for public topics:
import { WebsocketClient } from '@siebly/kraken-api';
const wsClient = new WebsocketClient();
wsClient.on('open', (data) => {
console.log('WebSocket connected: ', data?.wsKey);
});
wsClient.on('message', (data) => {
console.log('Data received: ', JSON.stringify(data, null, 2));
});
wsClient.on('reconnected', (data) => {
console.log('WebSocket reconnected: ', data);
});
wsClient.on('exception', (data) => {
console.error('WebSocket error: ', data);
});
wsClient.subscribe(
{
topic: 'ticker',
payload: {
symbol: ['BTC/USD', 'ETH/USD'],
},
},
'spotPublicV2',
);
Notice that WebSocket symbols use BTC/USD, while the Spot REST ticker example uses XBTUSD. That difference comes from Kraken’s APIs, not from the SDK. Private streams and Spot WebSocket API commands need credentials; the full tutorial covers those clients, including WebsocketAPIClient.
Further reading
The Kraken JavaScript SDK page has a first-request walkthrough and the client map. The Kraken SDK docs list REST and WebSocket methods, and the source is at sieblyio/kraken-api. Official endpoint behaviour is documented in the Kraken API docs. The SDK is open source and part of the Siebly family of exchange SDKs, with over 4.5 million npm downloads across 10+ SDKs, with more in the works. The full list is at siebly.io/sdk.
Disclosure: this guide is published by Siebly, the maintainers of the @siebly/kraken-api npm package.

