Skip to content

Node.js quickstart with JavaScript ​

Install @siebly/kraken-api and read the Bitcoin/USD Spot ticker with SpotClient. This example uses plain JavaScript, with no TypeScript compiler or API credentials.

Installation ​

TypeScript definitions are included.

Install the npm package with your preferred tool:

sh
npm install @siebly/kraken-api
sh
pnpm add @siebly/kraken-api
sh
yarn add @siebly/kraken-api
sh
bun add @siebly/kraken-api
sh
deno add npm:@siebly/kraken-api
text
Package: @siebly/kraken-api
npm: https://www.npmjs.com/package/@siebly/kraken-api

For other npm-compatible tools, use the same package from npm. Runtime-specific setup is covered below.

Choose your setup ​

Follow the guide for your runtime or framework. Each includes a complete project with commands to install dependencies and run it.

SetupGuides
Node.jsJavaScript or TypeScript
Alternative runtimesBun or Deno
Browser appsReact with Vite or Vite with plain JavaScript
Next.jsNode.js server Route Handler
Cloudflare WorkersPublic prices and authenticated orders
Mobile appsReact Native / Expo for iOS and Android

Browser and Expo guides include SDK-specific bundler configuration and polyfills where needed. See Runtime compatibility for tested versions, required configuration and what the checks cover.

Use Node.js 24 for this quickstart. For other runtimes and required polyfills, see Runtime compatibility.

Make a request ​

Save this as prices.mjs:

js
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;
});

Run it with:

sh
node prices.mjs

Example output ​

text
XXBTZUSD last price: 65000.00000

Your price will differ. The loop reads each returned pair name from result, since Kraken may return a different name from the requested alias. The first entry in c is the last trade price.

Module formats ​

The .mjs extension selects ES modules. In a CommonJS .cjs file, use const { SpotClient } = require('@siebly/kraken-api') and retain the async main() function. TypeScript uses the same imports with the package's included types.

Next steps ​

Market data · WebSocket subscriptions · Choose a client · Troubleshooting

TypeScript integrations ​

The SDK works with both JavaScript and TypeScript. TypeScript is optional, but we strongly recommend it for SDK integrations: the included types help catch invalid method names, parameter shapes and response assumptions at build time, before requests reach the exchange. If you choose TypeScript, follow the TypeScript setup and run npx tsc --noEmit during development and CI. Type checking does not replace runtime validation or exchange-side checks.

Some runtimes can execute TypeScript directly. For example, Node.js type stripping supports erasable TypeScript syntax without a separate compiler, but does not check types. If your runtime cannot execute the syntax used by a TypeScript example, compile that example to JavaScript or use a compatible TypeScript runner. Examples with local .js imports that refer to TypeScript source files can use the compiler-based setup above. Plain JavaScript usage does not need any TypeScript tooling.

See Testing without orders for ways to validate your integration without placing orders.

Built by Siebly. Open source SDKs for exchange APIs.