SDK guide
JavaScript
REST API + WebSocket

Kraken JavaScript SDK

Build with the Kraken REST API & WebSockets with our JavaScript SDK, TypeScript-first package declarations, and Node.js-compatible runtime patterns. Discover installation, common examples, a detailed endpoint-to-function map, and the REST API/WebSocket patterns shared across our Siebly SDK family.

Use the same TypeScript-first REST API and WebSocket clients from plain JavaScript or TypeScript in Node.js-compatible runtimes.

Package surfaces

Explore the following API capabilities are covered by our Kraken SDK:

  • Spot
  • Futures
  • WebSockets
  • WebSocket API
  • WebSocket clients with:
    • Built-in heartbeats.
    • Automatic reconnection.
    • Automatic reauthentication and resubscribe where the exchange supports it.
  • Promise-wrapped WebSocket API commands you can await like a REST API.
  • Typed requests and responses for Node.js, JavaScript, and TypeScript IDEs.
  • Framework-neutral JavaScript snippets that stay approachable in Node.js-compatible runtimes.
  • TypeScript-first package declarations for stricter services, shared libraries, and editor-assisted integrations.

Install Kraken SDK

# Via your favourite package manager, e.g. npm:
npm install @siebly/kraken-api
# or pnpm:
pnpm install @siebly/kraken-api
# or yarn:
yarn add @siebly/kraken-api

Quickstart Examples with the Kraken JavaScript SDK

Get started with just a few lines of JavaScript. TypeScript, while not required, is absolutely recommended. TypeScript declarations are included with all our SDKs and provide convenient definitions on request & response fields, WebSocket payloads, and generally safer integrations.

REST walkthrough

Easily start working with Kraken Derivatives REST APIs in JavaScript.

  • Install the Kraken JavaScript SDK via NPM: npm install @siebly/kraken-api.
  • Import the DerivativesClient class for Kraken futures and derivatives REST endpoints.
    • If spot is preferred, import the SpotClient, which is the dedicated utility class wrapped around Kraken's Spot REST APIs.
  • Create an authenticated DerivativesClient instance with your API credentials.
  • Call REST API methods as functions and await their responses.

In this example, we:

  • Edit an existing order by updating parameters such as the limit price.
  • Cancel a single open order by order_id.
  • Cancel all open orders on the account.
  • Cancel all open orders for a specific symbol such as PF_ETHUSD.
  • Demonstrate batch order management by combining edit and cancel actions in one request.

This script is designed as a practical order management walkthrough for Kraken Derivatives, showing common authenticated API calls in JavaScript and the shapes of the request payloads involved.

For a full map of available REST API methods, check out the endpoint reference below.

/* eslint-disable @typescript-eslint/no-unused-vars */// This example shows how to call Kraken API endpoint with either node.js,// javascript (js) or typescript (ts) with the npm module "@siebly/kraken-api" for Kraken exchange// for ORDER MANAGEMENT import { DerivativesClient } from '@siebly/kraken-api'; // initialise the client/** * * Kraken Futures API uses API Key and API Secret * * Example: * { *   apiKey: 'your-api-key', *   apiSecret: 'your-api-secret', * } */const client = new DerivativesClient({  apiKey: process.env.API_FUTURES_KEY || 'insertApiKeyHere',  apiSecret: process.env.API_FUTURES_SECRET || 'insertApiSecretHere',});async function editOrder() {  try {    // Edit an existing order    const editResult = await client.editOrder({      orderId: 'a04d0f84-36d4-4499-8382-96fcfc3ce7aa', // Or use cliOrdId instead      limitPrice: 1100, // New limit price      // or add some other parameters you want to edit    });    console.log('Edit Order Result: ', JSON.stringify(editResult, null, 2));     // Response includes:    // - status: edited, invalidSize, invalidPrice, etc.    // - orderEvents: Array of order events  } catch (e) {    console.error('Edit order error: ', e);  }} async function cancelOrder() {  try {    // Cancel a single order    const cancelResult = await client.cancelOrder({      order_id: 'a04d0f84-36d4-4499-8382-96fcfc3ce7aa', // Or use cliOrdId    });    console.log('Cancel Order Result: ', JSON.stringify(cancelResult, null, 2));     // Response status:    // - cancelled: Successfully cancelled    // - filled: Order was already filled    // - notFound: Order not found  } catch (e) {    console.error('Cancel order error: ', e);  }} async function cancelAllOrders() {  try {    // Cancel all open orders    const cancelAllResult = await client.cancelAllOrders();    console.log(      'Cancel All Orders Result: ',      JSON.stringify(cancelAllResult, null, 2),    );     // Response includes:    // - status: cancelled or noOrdersToCancel    // - cancelledOrders: Array of cancelled order IDs  } catch (e) {    console.error('Cancel all orders error: ', e);  }} async function cancelAllOrdersBySymbol() {  try {    // Cancel all orders for specific symbol    const cancelBySymbol = await client.cancelAllOrders({      symbol: 'PF_ETHUSD',    });    console.log(      'Cancel Orders by Symbol Result: ',      JSON.stringify(cancelBySymbol, null, 2),    );  } catch (e) {    console.error('Cancel orders by symbol error: ', e);  }} async function batchOrderManagement() {  try {    // Send, edit, and cancel orders in a single batch request    const batchResult = await client.batchOrderManagement({      json: {        batchOrder: [          // Edit existing order          {            order: 'edit',            order_id: 'a04d1143-757a-4dba-a0a7-687303b9c62d',            limitPrice: 900,          },          // Cancel existing order          {            order: 'cancel',            order_id: 'a04d116e-fb9c-4bcf-9eaf-ea90254439b3',          },        ],      },    });    console.log('Batch Order Result: ', JSON.stringify(batchResult, null, 2));     // Response includes batchStatus array with results for each order    // - status: placed, edited, cancelled, or rejection reason    // - order_tag: Maps back to your request  } catch (e) {    console.error('Batch order management error: ', e);  }} // Uncomment the function you want to test: // editOrder();// cancelOrder();// cancelAllOrders();// cancelAllOrdersBySymbol();// batchOrderManagement();
Full Kraken course

Kraken API JavaScript Tutorial

A richer JavaScript guide for building Kraken Spot REST, Futures REST, public and private WebSockets, WebSocket API trading, reconnect handling, and production rollout patterns with @siebly/kraken-api.

Spot and Futures clients
Public and private streams
Promise-wrapped WebSocket API trading
Production reconnect and backfill workflows
REST API
WebSocket Streams
WebSocket API
Examples

Your app / service

bot, dashboard, worker

@siebly/kraken-api

SpotClient, DerivativesClient, WebsocketClient

Kraken APIs

Spot REST, Futures REST, WebSockets, WebSocket API

Common Kraken implementation tasks

Endpoint Function Reference

Endpoint maps

Each REST client is a JavaScript class, which provides functions individually mapped to each endpoint available in the exchange's API offering.

The following table shows all methods available in each REST client, whether the method requires authentication (automatically handled if API keys are provided), as well as the exact endpoint each method is connected to.

This can be used to easily find which method to call, once you have found which endpoint you're looking to use.

All REST clients are in the src folder. For usage examples, make sure to check the examples folder.

List of clients:

If anything is missing or wrong, please open an issue or let us know in our Node.js Traders telegram group!

How to use table

Table consists of 4 parts:

  • Function name
  • AUTH
  • HTTP Method
  • Endpoint

Function name is the name of the function that can be called through the SDK. Check examples folder in the repo for more help on how to use them!

AUTH is a boolean value that indicates if the function requires authentication - which means you need to pass your API key and secret to the SDK.

HTTP Method shows HTTP method that the function uses to call the endpoint. Sometimes endpoints can have same URL, but different HTTP method so you can use this column to differentiate between them.

Endpoint is the URL that the function uses to call the endpoint. Best way to find exact function you need for the endpoint is to search for URL in this table and find corresponding function name.

SpotClient.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in SpotClient.ts.

FunctionAUTHHTTP MethodEndpoint
getSystemStatus()GET0/public/SystemStatus
getAssetInfo()GET0/public/Assets
getAssetPairs()GET0/public/AssetPairs
getTicker()GET0/public/Ticker
getCandles()GET0/public/OHLC
getOrderBook()GET0/public/Depth
getGroupedBook()GET0/public/GroupedBook
getLevel3OrderBook()🔐POST0/private/Level3
getRecentTrades()GET0/public/Trades
getRecentSpreads()GET0/public/Spread
getAccountBalance()🔐POST0/private/Balance
getApiKeyInfo()🔐POST0/private/GetApiKeyInfo
getExtendedBalance()🔐POST0/private/BalanceEx
getCreditLines()🔐POST0/private/CreditLines
getTradeBalance()🔐POST0/private/TradeBalance
getOpenOrders()🔐POST0/private/OpenOrders
getClosedOrders()🔐POST0/private/ClosedOrders
getOrders()🔐POST0/private/QueryOrders
getOrderAmends()🔐POST0/private/OrderAmends
getTradesHistory()🔐POST0/private/TradesHistory
getTrades()🔐POST0/private/QueryTrades
getOpenPositions()🔐POST0/private/OpenPositions
getLedgersInfo()🔐POST0/private/Ledgers
getLedgers()🔐POST0/private/QueryLedgers
getTradingVolume()🔐POST0/private/TradeVolume
requestLedgersExport()🔐POST0/private/AddExport
getLedgersExportStatus()🔐POST0/private/ExportStatus
getLedgersExport()🔐POST0/private/RetrieveExport
deleteLedgersExport()🔐POST0/private/RemoveExport
submitOrder()🔐POST0/private/AddOrder
amendOrder()🔐POST0/private/AmendOrder
cancelOrder()🔐POST0/private/CancelOrder
cancelAllOrders()🔐POST0/private/CancelAll
cancelAllOrdersAfter()🔐POST0/private/CancelAllOrdersAfter
getWebSocketsToken()🔐POST0/private/GetWebSocketsToken
submitBatchOrders()🔐POST0/private/AddOrderBatch
cancelBatchOrders()🔐POST0/private/CancelOrderBatch
getDepositMethods()🔐POST0/private/DepositMethods
getDepositAddresses()🔐POST0/private/DepositAddresses
getDepositsStatus()🔐POST0/private/DepositStatus
getWithdrawalMethods()🔐POST0/private/WithdrawMethods
getWithdrawalAddresses()🔐POST0/private/WithdrawAddresses
getWithdrawalInfo()🔐POST0/private/WithdrawInfo
submitWithdrawal()🔐POST0/private/Withdraw
getWithdrawalsStatus()🔐POST0/private/WithdrawStatus
cancelWithdrawal()🔐POST0/private/WithdrawCancel
submitTransferToFutures()🔐POST0/private/WalletTransfer
createSubaccount()🔐POST0/private/CreateSubaccount
submitSubaccountTransfer()🔐POST0/private/AccountTransfer
allocateEarnFunds()🔐POST0/private/Earn/Allocate
deallocateEarnFunds()🔐POST0/private/Earn/Deallocate
getEarnAllocationStatus()🔐POST0/private/Earn/AllocateStatus
getEarnDeallocationStatus()🔐POST0/private/Earn/DeallocateStatus
getEarnStrategies()🔐POST0/private/Earn/Strategies
getEarnAllocations()🔐POST0/private/Earn/Allocations
getPreTradeData()GET0/public/PreTrade
getPostTradeData()GET0/public/PostTrade
getOAuthAccessToken()POSToauth/token
getOAuthUserInfo()🔐GEToauth/userinfo
createOAuthFastApiKey()🔐POSToauth/fast-api-key
deleteOAuthFastApiKey()🔐DELETEoauth/fast-api-key
updateOAuthFastApiKey()🔐PUToauth/fast-api-key
listOAuthFastApiKeys()🔐GEToauth/fast-api-keys

DerivativesClient.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in DerivativesClient.ts.

FunctionAUTHHTTP MethodEndpoint
getTradeHistory()GETderivatives/api/v3/history
getOrderbook()GETderivatives/api/v3/orderbook
getTickers()GETderivatives/api/v3/tickers
getTicker()GETderivatives/api/v3/tickers/{symbol}
getInstruments()GETderivatives/api/v3/instruments
getInstrumentStatusList()GETderivatives/api/v3/instruments/status
getInstrumentStatus()GETderivatives/api/v3/instruments/{symbol}/status
batchOrderManagement()🔐POSTderivatives/api/v3/batchorder
cancelAllOrders()🔐POSTderivatives/api/v3/cancelallorders
cancelAllOrdersAfter()🔐POSTderivatives/api/v3/cancelallordersafter
cancelOrder()🔐POSTderivatives/api/v3/cancelorder
editOrder()🔐POSTderivatives/api/v3/editorder
getOpenOrders()🔐GETderivatives/api/v3/openorders
submitOrder()🔐POSTderivatives/api/v3/sendorder
getOrderStatus()🔐POSTderivatives/api/v3/orders/status
getPnlPreferences()🔐GETderivatives/api/v3/pnlpreferences
setPnlPreference()🔐PUTderivatives/api/v3/pnlpreferences
getLeverageSettings()🔐GETderivatives/api/v3/leveragepreferences
setLeverageSettings()🔐PUTderivatives/api/v3/leveragepreferences
getAccounts()🔐GETderivatives/api/v3/accounts
getOpenPositions()🔐GETderivatives/api/v3/openpositions
getPositionPercentile()🔐GETderivatives/api/v3/unwindqueue
getPortfolioMarginParameters()🔐GETderivatives/api/v3/portfolio-margining/parameters
simulateMarginRequirements()🔐POSTderivatives/api/v3/portfolio-margining/simulate
getAssignmentPrograms()🔐GETderivatives/api/v3/assignmentprogram/current
addAssignmentPreference()🔐POSTderivatives/api/v3/assignmentprogram/add
deleteAssignmentPreference()🔐POSTderivatives/api/v3/assignmentprogram/delete
getAssignmentPreferencesHistory()🔐GETderivatives/api/v3/assignmentprogram/history
getFeeSchedules()GETderivatives/api/v3/feeschedules
getFeeScheduleVolumes()🔐GETderivatives/api/v3/feeschedules/volumes
getNotifications()🔐GETderivatives/api/v3/notifications
getFills()🔐GETderivatives/api/v3/fills
getHistoricalFundingRates()GETderivatives/api/v3/historical-funding-rates
getSelfTradeStrategy()🔐GETderivatives/api/v3/self-trade-strategy
updateSelfTradeStrategy()🔐PUTderivatives/api/v3/self-trade-strategy
getSubaccountTradingStatus()🔐GETderivatives/api/v3/subaccount/{subaccountUid}/trading-enabled
updateSubaccountTradingStatus()🔐PUTderivatives/api/v3/subaccount/{subaccountUid}/trading-enabled
getSubaccounts()🔐GETderivatives/api/v3/subaccounts
submitWalletTransfer()🔐POSTderivatives/api/v3/transfer
submitSubaccountTransfer()🔐POSTderivatives/api/v3/transfer/subaccount
submitTransferToSpot()🔐POSTderivatives/api/v3/withdrawal
getOpenRFQs()GETderivatives/api/v3/rfqs
getOpenRFQ()GETderivatives/api/v3/rfqs/{rfqUid}
getRFQOpenOffers()🔐GETderivatives/api/v3/rfqs/open-offers
submitRFQNewOffer()🔐POSTderivatives/api/v3/rfqs/{rfqUid}/place-offer
updateRFQOpenOffer()🔐PUTderivatives/api/v3/rfqs/{rfqUid}/replace-offer
cancelRFQOffer()🔐DELETEderivatives/api/v3/rfqs/{rfqUid}/cancel-offer
getExecutionEvents()🔐GETapi/history/v3/executions
getOrderEvents()🔐GETapi/history/v3/orders
getTriggerEvents()🔐GETapi/history/v3/triggers
getPositionEvents()🔐GETapi/history/v3/positions
getAccountLog()🔐GETapi/history/v3/account-log
getAccountLogCsv()🔐GETapi/history/v3/accountlogcsv
getPublicExecutionEvents()GETapi/history/v3/market/{tradeable}/executions
getPublicOrderEvents()GETapi/history/v3/market/{tradeable}/orders
getPublicMarkPriceEvents()GETapi/history/v3/market/{tradeable}/price
getTickTypes()GETapi/charts/v1/
getMarketsForTickType()GETapi/charts/v1/{tickType}
getResolutions()GETapi/charts/v1/{tickType}/{symbol}
getCandles()GETapi/charts/v1/{tickType}/{symbol}/{resolution}
getLiquidityPoolStatistic()GETapi/charts/v1/analytics/liquidity-pool
getMarketAnalytics()GETapi/charts/v1/analytics/{symbol}/{analyticsType}
checkApiKeyV3()🔐GETapi/auth/v1/api-keys/v3/check
getAccountMarketShare()🔐GETapi/stats/v1/rebates/self-market-share

InstitutionalClient.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in InstitutionalClient.ts.

FunctionAUTHHTTP MethodEndpoint
listCustodyVaults()🔐POST0/private/ListCustodyVaults
getCustodyVaultbyId()🔐POST0/private/GetCustodyVault
getCustodyDepositMethods()🔐POST0/private/DepositMethods
getCustodyDepositAddresses()🔐POST0/private/DepositAddresses
listCustodyTransactions()🔐POST0/private/ListCustodyTransactions
getCustodyTransactionbyId()🔐POST0/private/GetCustodyTransaction
getCustodyWithdrawMethods()🔐POST0/private/WithdrawMethods
getCustodyWithdrawAddresses()🔐POST0/private/WithdrawAddresses
listCustodyTasks()🔐POST0/private/ListCustodyTasks
getCustodyTaskbyId()🔐POST0/private/GetCustodyTask
listCustodyActivities()🔐POST0/private/ListCustodyActivities
getCustodyActivitybyId()🔐POST0/private/GetCustodyActivity
createOtcQuoteRequest()🔐POST0/private/CreateOtcQuoteRequest
updateOtcQuote()🔐POST0/private/UpdateOtcQuote
getOtcPairs()🔐POST0/private/GetOtcPairs
getOtcActiveQuotes()🔐POST0/private/GetOtcActiveQuotes
getOtcHistoricalQuotes()🔐POST0/private/GetOtcHistoricalQuotes
getOtcExposures()🔐POST0/private/GetOtcExposures
checkOtcClient()🔐POST0/private/CheckOtcClient

PartnerClient.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in PartnerClient.ts.

FunctionAUTHHTTP MethodEndpoint
createEmbedUser()🔐POSTb2b/users
getEmbedUser()🔐GETb2b/users/{user}
updateEmbedUser()🔐PATCHb2b/users/{user}
submitEmbedVerification()🔐POSTb2b/verifications/{user}
listEmbedAssets()🔐GETb2b/assets
getEmbedAsset()🔐GETb2b/assets/{asset}
listEmbedAssetRates()🔐GETb2b/assets/{asset}/rates
requestEmbedQuote()🔐POSTb2b/quotes
getEmbedQuote()🔐GETb2b/quotes/{quote_id}
executeEmbedQuote()🔐PUTb2b/quotes/{quote_id}
getEmbedQuoteLimits()🔐GETb2b/quotes/limits
requestEmbedProspectiveQuote()🔐POSTb2b/quotes/prospective
createEmbedCustomOrder()🔐POSTb2b/custom-orders
listEmbedCustomOrders()🔐GETb2b/custom-orders
getEmbedCustomOrder()🔐GETb2b/custom-orders/{order_id}
cancelEmbedCustomOrder()🔐POSTb2b/custom-orders/{id}/cancel
getEmbedPortfolioSummary()🔐GETb2b/portfolio/{user}/summary
getEmbedPortfolioHistory()🔐GETb2b/portfolio/{user}/history
listEmbedPortfolioDetails()🔐GETb2b/portfolio/{user}/details
listEmbedPortfolioTransactions()🔐GETb2b/portfolio/{user}/transactions
getEmbedEarnSummary()🔐GETb2b/earn/{user}
listEmbedEarnAssets()🔐GETb2b/earn/assets
toggleEmbedAutoEarn()🔐PUTb2b/earn/{user}/auto
withdrawEmbedFunds()🔐POSTb2b/funds/withdrawals
listEmbedFundingTransactions()🔐GETb2b/funds/transactions
listEmbedSettlementReports()🔐GETb2b/reports/settlement
getEmbedSettlementReport()🔐GETb2b/reports/settlement/{id}
listRampBuyCryptoAssets()🔐GETb2b/ramp/buy/crypto
listRampFiatCurrencies()🔐GETb2b/ramp/fiat-currencies
listRampPaymentMethods()🔐GETb2b/ramp/payment-methods
listRampCountries()🔐GETb2b/ramp/countries
getRampLimits()🔐GETb2b/ramp/limits
getRampProspectiveQuote()🔐GETb2b/ramp/quotes/prospective
getRampCheckoutUrl()🔐GETb2b/ramp/checkout

WebsocketAPIClient.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in WebsocketAPIClient.ts.

This client provides WebSocket API endpoints which allow for faster interactions with the Kraken API via a WebSocket connection.

FunctionAUTHHTTP MethodEndpoint
submitSpotOrder()🔐WSadd_order
amendSpotOrder()🔐WSamend_order
cancelSpotOrder()🔐WScancel_order
cancelAllSpotOrders()🔐WScancel_all
cancelAllSpotOrdersAfter()🔐WScancel_all_orders_after
batchSubmitSpotOrders()🔐WSbatch_add
batchCancelSpotOrders()🔐WSbatch_cancel
editSpotOrder()🔐WSedit_order
View endpoint map sourceShowing the available endpoint reference map.

Kraken JavaScript FAQ

What does the Kraken JavaScript SDK cover?

Kraken supports Spot, Futures, WebSockets, and WebSocket API workflows. The JavaScript guide covers the main REST and WebSocket integration patterns.

How do I authenticate private Kraken API calls in JavaScript?

Install @siebly/kraken-api from npm & pass API credentials into the SDK client options, as shown in the Kraken JavaScript examples above. The SDK handles the exchange-specific signing requirements for private requests.

Does the Kraken JavaScript SDK help with WebSocket connection management?

Yes. Use the SDK WebSocket client for subscriptions, reconnect handling, and stream lifecycle management instead of building raw socket flows yourself.

When should I use the Kraken WebSocket API instead of REST?

Use REST for standard request and response workflows such as account queries and order management. Use the WebSocket API flow when you want persistent low-latency interactions over a connected session.

Direct Example Files

Continue with implementation resources

Subscribe on Substack

Complete the Substack form below to join our newsletter. Substack handles all subscriber data directly.