Skip to content

TypeScript SDK ​

Official TypeScript SDK for the FAST platform, version 4.0.0. Zero dependencies. Works in Node.js 18+, Deno, Bun, and edge runtimes. Every amount it sends and returns is EUR with at most 2 decimals.

The SDK holds a server key, so run it on your backend. In a browser it refuses to start with anything but a public pk_ key unless you pass dangerouslyAllowBrowser: true.


Install ​

bash
npm install @fundedfast/sdk

Quick Start ​

typescript
import { FastClient } from '@fundedfast/sdk';

const fast = new FastClient({ apiKey: process.env.FAST_API_KEY! });

// Forward a bet
await fast.bets.ingest({
  userId: 'player-42',
  externalBetId: 'BET-001',
  stakeAmount: 5.00,
  odds: 2.10,
  status: 'placed',
});

// Check progress
const progress = await fast.users.getProgress('player-42');

Namespaces ​

Operator (integration) ​

NamespacePurpose
fast.challengesPurchase, list tiers, tier terms, leaderboard
fast.betsValidate, ingest, batch ingest
fast.usersProgress, ruleset, history, timeline, payout state (getWithdrawable), payouts (withdraw, listPayoutRequests), continue, refund and cancel choices, achievements, rewards, tournaments, loyalty
fast.eventsSSE token issuance and stream URL
fast.reconciliationCross-reference bet data
fast.widgetWidget module toggles and branding config
fast.sandboxReset staging data, time travel for one user (timeTravel)

The user actions of the engagement modules sit with their admin namespace but call the user routes, so they work with an integration key too: fast.admin.bonuses.activate, fast.admin.missions.join and fast.admin.tournaments.join.

Admin (backoffice) ​

Every fast.admin.* call to a /v1/admin/*, /v1/audit/* or /v1/analytics/* route needs a server key with the admin scope. A production key has the integration scope unless FAST changed it, and gets 403 insufficient_scope here. See Authentication.

NamespacePurpose
fast.admin.challengeTiersCRUD challenge tiers
fast.admin.rulesetsCRUD rulesets
fast.admin.betsList, settle, bulk operations
fast.admin.payoutsPayout requests (list, confirm, reject) and the funded accounts overview
fast.admin.webhooksDeliveries, retry, dead letters, rotate secret, post-bet hook dead letters
fast.admin.settingsIntegration mode, URLs, theme, currency, timezone, settlement hold, widget layout
fast.admin.payoutsPayout requests (list, confirm, reject), funded accounts overview, accounts that need a decision
fast.admin.bonusesOffers, active bonuses, stats
fast.admin.missionsCRUD missions, stats, enroll users in a targeted mission (enroll)
fast.admin.tournamentsCRUD tournaments, cancel, settle, invite
fast.admin.loyaltyConfig, tiers, user management
fast.admin.achievementsCRUD achievements, grant, GDPR export/erase
fast.admin.rewardsGrant, revoke, history
fast.admin.rewardRulesCRUD reward rules
fast.admin.selfExclusionExclude/lift users
fast.admin.adaptersPayload field mapping
fast.admin.reconciliationReconciliation flags
fast.admin.auditAudit log queries, GDPR bulk export, retention policy
fast.admin.analyticsOverview, challenges, revenue, users, funnel, engagement, benchmarks
fast.admin.notificationChannelsSlack/Teams/Discord/custom channels
fast.admin.usersUser lookup, revoke funded account
fast.admin.templatesBrowse and clone challenge templates
fast.admin.supportSupport requests to the FAST team
typescript
// Hold a win's profit for 48 hours before it can be paid out (0 to 168)
const { settlementHoldHours } = await fast.admin.settings.setSettlementHold(48);

// Funded accounts FAST cannot settle on its own
const decisions = await fast.admin.payouts.needsDecision();
for (const d of decisions) {
  if (d.kind === 'final_payout_rejected') console.log(d.userId, d.rejectedRequest?.amount);
}

Configuration ​

typescript
const fast = new FastClient({
  apiKey: 'key-...',
  baseUrl: 'https://api.fundedfast.eu/v1',  // default
  timeout: 10_000,                           // default 10s
  retry: { maxRetries: 3 },                  // exponential backoff; POSTs reuse one X-Idempotency-Key across retries
                                             // retry: false turns retries off
  debug: false,                              // console logging, key redacted
  headers: { 'X-Request-Source': 'backend' },// extra headers on every request
  fetch: customFetch,                        // your own fetch implementation

  // Observability hooks
  onRequest: ({ method, url }) => logger.info(`${method} ${url}`),
  onResponse: ({ status, durationMs }) => metrics.record(status, durationMs),
});

The retry defaults are maxRetries: 3, initialDelay: 300, maxDelay: 10000 (ms) and retryableStatuses: [429, 500, 502, 503, 504].


Error Handling ​

typescript
import { FastApiError, FastTimeoutError, FastNetworkError } from '@fundedfast/sdk';

try {
  await fast.bets.ingest(bet);
} catch (err) {
  if (err instanceof FastApiError) {
    // err.status, err.code, err.correlationId, err.isRetryable
  } else if (err instanceof FastTimeoutError) {
    // err.timeoutMs
  } else if (err instanceof FastNetworkError) {
    // err.cause
  }
}

Webhook Verification ​

typescript
import { verifyWebhookSignature, parseWebhookEvent } from '@fundedfast/sdk/webhooks';

const valid = await verifyWebhookSignature(rawBody, signature, secret);
const event = parseWebhookEvent(rawBody);

rawBody must be the request body exactly as received (a string), not JSON.stringify of a parsed object; signature is the X-Webhook-Signature header.

To keep working through a secret rotation, check the whole request instead. It tries every secret you pass against both X-Webhook-Signature and X-Webhook-Signature-Previous:

typescript
import { verifyWebhookRequest } from '@fundedfast/sdk/webhooks';

const valid = await verifyWebhookRequest(rawBody, req.headers, [newSecret, oldSecret]);

See Rotating the secret.


Dual Build ​

Ships ESM and CommonJS. Both fully typed.

typescript
// ESM
import { FastClient } from '@fundedfast/sdk';

// CommonJS
const { FastClient } = require('@fundedfast/sdk');

BLACKLINE CONSULTING d.o.o.