This version (v0.7) has not been published to npm yet.
Skip to content

Core ​

@getenginex/sdk is the core of the SDK: the client (createEnginexClient), the session and its tokens, the tenant, errors and the flows every player app needs, independent of product: account, operator configuration, wallet and PIX, KYC, responsible gaming, notifications and realtime. The product packages (iGaming and Predictions) and the framework adapters (Frameworks) are built on top of it.

NamespaceWhat it does
authsign-up, login and 2FA and password
configoperator configuration and branding; the support widget
profilethe player's profile and sessions
wallet, depositsbalance and statement; PIX deposit (live balance)
withdrawalswithdrawal with OTP
pixKeysthe player's PIX keys
kycidentity verification
responsibleGamblingresponsible gaming
notificationsnotifications

Installation ​

bash
npm i @getenginex/sdk
# or
pnpm add @getenginex/sdk

The core has no peer dependencies. Its only dependency is zod 4 (a regular dependency, shared with the product packages when the ranges match; see a single zod copy).

  • Runtimes: browsers with fetch and AbortController, Node 20+, edge runtimes and Bun, as ESM and CommonJS.
  • crypto.randomUUID: only the methods that send an Idempotency-Key (the ones that move money, such as deposits.createPix) generate keys. Without randomUUID (an insecure origin, such as HTTP on the LAN) the SDK falls back to crypto.getRandomValues; with no Web Crypto at all, those methods reject with CONFIGURATION_ERROR.
  • Gateway: by default the SDK calls /api/v1/... on the page's own origin. Proxy /api to the EngineX gateway (Proxy to the gateway).

Entry points ​

ImportWhat it brings
@getenginex/sdkcreateEnginexClient, token stores, EnginexError/isEnginexError and the namespaces above
@getenginex/sdk/realtimecreateRealtime and coreTopics (Realtime)
@getenginex/sdk/queryquery and mutation factories for TanStack Query v5 (Frameworks)
@getenginex/sdk/testingcreateMockFetch and createMockRealtime (Testing and mocks)
@getenginex/sdk/extensionthe contract for SDK packages, not for apps (Extensibility)

Each entry is a separate file: an app that does not import /realtime loads no WebSocket code, and /testing never reaches a production bundle that does not import it.

Create the client ​

Create one client per app in the browser and export it:

ts
// enginex.ts
import { createEnginexClient, localStorageTokenStore } from '@getenginex/sdk'

export const enginex = createEnginexClient({
  locale: 'pt-BR',
  tokenStore: localStorageTokenStore(),
  onSessionExpired: () => location.assign('/login'),
})

const config = await enginex.config.get()

On the server (SSR, scripts, tests), create one client per request, with baseUrl and tenantHost. The full walkthrough (login, session, language and disposal) is in Getting started; the options are in Session and tokens and Tenant and domains.

Products and frameworks ​

The product packages take the core client and reuse its session, tenant, hooks and validation:

ts
import { createIgaming } from '@getenginex/sdk-igaming'
import { createPredictions } from '@getenginex/sdk-predictions'

export const igaming = createIgaming(enginex)
export const predictions = createPredictions(enginex)

They declare the core as a peer dependency (>=0.6.0 <1.0.0): install the core once, at the top of the app. For React, Next.js and Vue, see Frameworks.

Testing ​

@getenginex/sdk/testing runs the whole client without a gateway: createMockFetch() answers the core routes with data that passes the SDK's schemas, and createMockRealtime() is a fake WebSocket. See Testing and mocks.