Skip to content

Installation

The KINGSTONE SDK is a TypeScript client library for the KINGSTONE B2B Partner API. It wraps all partner endpoints with a fully typed interface, handles authentication, JSON serialization, and error mapping automatically.

Requirements

  • Node.js 20+ (uses native fetch)
  • TypeScript 5+ (optional but recommended)

Install from npm

bash
npm install @kingstone/sdk

The package has zero runtime dependencies. It uses the native fetch API built into Node.js 20, so there is nothing else to install.

What Is Included

ExportDescription
KingstoneClientThe main API client class
KingstoneClientOptionsConstructor options type
KingstoneApiErrorError class for API errors
All response typesTypeScript interfaces for every endpoint response

Module Format

The SDK ships both ESM and CommonJS builds:

typescript
// ESM (recommended)
import { KingstoneClient, KingstoneApiError } from '@kingstone/sdk';

// CommonJS
const { KingstoneClient, KingstoneApiError } = require('@kingstone/sdk');

TypeScript Support

TypeScript types are included in the package — there is no separate @types/ package to install. You get full autocomplete and type checking out of the box.

typescript
import { KingstoneClient, type SpinResponse } from '@kingstone/sdk';

const client = new KingstoneClient({
  apiKey: 'ks_sandbox_your_key_here',
  sandbox: true,
});

// Full type inference on the response
const result: SpinResponse = await client.spin({
  gameId: 1,
  playerId: 'player-abc',
  wagerUsd: 0.25,
});

// Autocomplete works for all nested fields
console.log(result.outcome.prizeTier);
console.log(result.presentation.comboString);
console.log(result.balance.balanceUsd);

Quick Verify

After installing, verify the SDK is working:

typescript
import { KingstoneClient } from '@kingstone/sdk';

const client = new KingstoneClient({
  apiKey: 'ks_sandbox_your_key_here',
  sandbox: true,
});

const { games } = await client.listGames();
console.log(`Connected. Found ${games.length} game(s).`);

Next Steps

KINGSTONE by Predigy Inc.