Skip to documentation
/

Node.js SDK

Install the SDK#

Download the JavaScript / TypeScript package, then install it from your download directory. This is a downloadable package; it is not published to the npm registry.

bash example
.sh
npm install ./aggregator-network-sdk-0.1.1.tgz

Requires Node.js 22 or newer. The SDK runs on your backend. React, mobile and other frontend applications call your own backend; never bundle a Game API key into an application delivered to players.

Run a complete starter#

Download the JavaScript and TypeScript starter. It includes the SDK archive and executable examples.

bash example
.sh
unzip aggregator-network-sdk-starter-0.1.1.zipcd aggregator-network-sdk-starter-0.1.1cp .env.example .envnpm installnpm run providers:js

The providers example uses the public directory and needs no API key. For entitled workspace games, put your key and currency in the private .env file and run npm run catalogue:js. For TypeScript, run npm run build, then npm run providers:ts or npm run catalogue:ts. The starter supplies NodeNext compilation; JavaScript uses .mjs directly.

Configure your client#

Create a scoped Game API key and configure the backend egress IP and return origins in API Setup. Store the key in your server environment.

typescript example
.ts
import { AggregatorClient } from '@aggregator-network/sdk'; const apiKey = process.env.AGGREGATOR_API_KEY;if (!apiKey) throw new Error('AGGREGATOR_API_KEY is required'); const client = new AggregatorClient({  apiKey,  baseUrl: 'https://aggregatornetwork.com',  timeoutMs: 15_000,}); const catalogue = await client.getGameList({  currency: 'USD',  list_type: 2,});

The SDK uses the existing gateway, returns the complete response envelope and rejects unsuccessful HTTP responses or a nonzero numeric API error. Keep catalogue identifiers exactly as returned; do not substitute a numeric database ID.

Launch a demo#

Use a game identifier from your entitled catalogue and HTTPS return origins saved in API Setup. Demo eligibility and provider support still apply. This example creates a real temporary demo URL when run with an eligible key.

typescript example
.ts
const demo = await client.getGameDemo({  gameid: 'REPLACE_WITH_CATALOGUE_ID',  currency: 'USD',  lang: 'en',  homeurl: 'https://operator.example/lobby',  cashierurl: 'https://operator.example/cashier',});// Deliver demo.response only to the requesting player.

See demo parameters and errors.

Persist mutation identities#

Create-player, funded launch and free-round mutations require an idempotency key. Persist the key and the exact request before sending. Reuse the same key only for that same operation; never generate a replacement key to resolve an unknown outcome.

typescript example
.ts
const player = await client.createPlayer(  { user_username: 'player-1001', currency: 'USD' },  { idempotencyKey: 'create-player-persisted-operation-001' },);

Creating a player does not fund a session. Read launch parameters and reconciliation rules before enabling funded play. The SDK does not automatically retry requests or reserve money in your own wallet.

Methods#

SDK methodExisting platform capabilityGuide
listProvidersPublic provider directoryProviders
getGameListWorkspace game catalogueCatalogue
getGameDemoTemporary trial-play launchDemo
createPlayerWorkspace player identityPlayer
getGameFunded game sessionLaunch
addFreeRoundsGrant supported free roundsGrant rounds
deleteFreeRoundsCancel unused supported roundsCancel rounds

Errors and recovery#

Catch SDK errors at your backend boundary and provide a safe message to the player. Keep keys, callback secrets and temporary game URLs out of logs. A timeout or connection failure after dispatch can mean the operation succeeded upstream. Reconcile your request record before changing funds or retrying a mutation.

Authentication, currency entitlement, activation, rate limits and wallet rules remain enforced by the gateway. See validation and recovery for the response contract.

Wallet callbacks#

The SDK's callback verifier authenticates exact delivered bytes with the separate callback signing secret. Signature verification alone does not prevent replay. Use durable, atomic deduplication by serial_number and reconcile ordering before applying balances. Monetary callback values need a lossless decimal parser and decimal storage; ordinary JSON.parse can lose precision.

typescript example
.ts
import { verifySettlementCallback } from '@aggregator-network/sdk'; // rawBody must be the untouched Uint8Array or Buffer from the request.const valid = verifySettlementCallback(rawBody, signatureHeader, callbackSecret);if (!valid) {  // Reject before parsing, enqueueing or applying any balance change.}

See the full receiver contract for signature format, durable acceptance, duplicate handling and delivery limits.

Scope and versioning#

This initial 0.1.1 package wraps the current HTTP gateway. It does not provide sportsbook odds streams, a CMS, payment acquiring, a Flutter package or React hooks. Existing website tools and account operations remain available in your workspace. Validate an SDK upgrade in your own integration environment before production rollout.

Was this page helpful?