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.
| Namespace | What it does |
|---|---|
auth | sign-up, login and 2FA and password |
config | operator configuration and branding; the support widget |
profile | the player's profile and sessions |
wallet, deposits | balance and statement; PIX deposit (live balance) |
withdrawals | withdrawal with OTP |
pixKeys | the player's PIX keys |
kyc | identity verification |
responsibleGambling | responsible gaming |
notifications | notifications |
Installation
npm i @getenginex/sdk
# or
pnpm add @getenginex/sdkThe 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
fetchandAbortController, Node 20+, edge runtimes and Bun, as ESM and CommonJS. crypto.randomUUID: only the methods that send anIdempotency-Key(the ones that move money, such asdeposits.createPix) generate keys. WithoutrandomUUID(an insecure origin, such as HTTP on the LAN) the SDK falls back tocrypto.getRandomValues; with no Web Crypto at all, those methods reject withCONFIGURATION_ERROR.- Gateway: by default the SDK calls
/api/v1/...on the page's own origin. Proxy/apito the EngineX gateway (Proxy to the gateway).
Entry points
| Import | What it brings |
|---|---|
@getenginex/sdk | createEnginexClient, token stores, EnginexError/isEnginexError and the namespaces above |
@getenginex/sdk/realtime | createRealtime and coreTopics (Realtime) |
@getenginex/sdk/query | query and mutation factories for TanStack Query v5 (Frameworks) |
@getenginex/sdk/testing | createMockFetch and createMockRealtime (Testing and mocks) |
@getenginex/sdk/extension | the 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:
// 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:
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.