SDKsTypeScript

TypeScript SDK

@membber/sdk-ts is a thin, fully typed client over the platform contract: every path, parameter, request body and response is typed end to end, generated from the same source as this reference.

Install

Honest status

The package is not on npm yet; publishing is planned. Today it ships inside the Membber platform workspace, and we provide it directly to teams building with us. If that is you, get in touch and we will set you up. Everything on this page works identically once it is on npm.

The SDK targets Node 18+ and modern bundlers, has a single runtime dependency (openapi-fetch), and works anywhere fetch exists, including edge runtimes.

Quickstart

Auth, first call, typed result
import { createMembberClient } from "@membber/sdk-ts";

const membber = createMembberClient({
  // Attached as "Authorization: Bearer <token>" on every request.
  getAccessToken: () => process.env.MEMBBER_TOKEN,
});

// Liveness probe, public, no auth needed:
const ping = await membber.systemPing({});
console.log(ping.data); // { ok: true, service: ..., version: ..., time: ... }

// A typed, authenticated read:
const { data, error } = await membber.raw.GET("/api/v1/loyalty/state", {
  params: { query: { customer_id: "<customer-id>" } },
});

if (error) {
  // error is the typed envelope: { error: { code, message, requestId } }
  console.error(error.error.code, error.error.message);
} else {
  console.log(data); // fully typed response body
}
  • Calls return { data, error } rather than throwing: exactly one of the two is set, and both are typed.
  • membber.raw is the full typed client: GET, POST, PATCH and PUT against any contract path, with the compiler checking parameters and bodies against the same schemas shown in the reference.
  • Named convenience methods exist for common operations: advanceOrderFulfilment, confirmOrder, createOrder, getCheckoutSettings, refundOrder, systemPing.

Using the contract types

Typed shapes
import type { paths, operations, components } from "@membber/sdk-ts";

// Every path, operation and schema from the contract is exported:
type CreateOrderBody =
  operations["createOrder"]["requestBody"]["content"]["application/json"];

Writes, retries and errors

Send an Idempotency-Key header on writes via the headers option, as shown in every write operation's TypeScript example in the reference. The idempotency, errors and rate limits guides apply unchanged: the SDK adds types, not behaviour.

WhatsApp
Book a Call
Start Free