Skip to content

Installation ​

The KINGSTONE SDK is a TypeScript client library for the KINGSTONE B2B Partner API. It provides a fully typed client for the partner endpoints — spins, games, PAR sheets, settlements, and webhooks — and 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 @kingstoneapp/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 '@kingstoneapp/sdk';

// CommonJS
const { KingstoneClient, KingstoneApiError } = require('@kingstoneapp/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 '@kingstoneapp/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);
// `presentation` is a 'slot' | 'raffle' union — narrow on `type` to read its fields.
if (result.presentation.type === 'slot') {
  console.log(result.presentation.comboString);
}
console.log(result.balance.balanceUsd);

Quick Verify ​

After installing, verify the SDK is working:

typescript
import { KingstoneClient } from '@kingstoneapp/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.