Introduction
gstable-js is the official Node.js 18+ client for the GStable Payment API. It gives you:
- Typed resources —
GStableClientexposes namespaces that mirror API areas (products, payment links, checkout sessions, webhooks, accounts, public capabilities). - Zero runtime dependencies — uses the platform
fetch; ships ESM and CJS with TypeScript declarations. - Envelope handling — parses the standard
{ code, message, data }response, returnsdataon success, and throwsGStableError(or subclasses) on failure. - Two HTTP modes — authenticated calls to the private base URL, and public calls (no
Authorization) for capability discovery.
Architecture (mental model)
GStableClientvalidatesapiKeyand constructsGStableHttpplus one*Resourceinstance per API domain (product, account, payment link, capability, checkout session, webhook).- Most resource methods call
http.requestJsonagainst the private base URL with aBearertoken. client.capability.all()useshttp.requestPublicJsonagainstpublicBaseUrland does not send anAuthorizationheader for that call.
What the SDK does not include
- Dashboard-only flows — Creating or editing merchant accounts is not available in the public API;
client.accountis read-only (list + detail). - Browser-first bundles — The package targets Node 18+. For browser apps, call your backend that uses the SDK, or proxy calls from a trusted server.
- Webhook signature verification helpers — The SDK manages webhook endpoints via the management API (
create,update,refreshKey, and so on). Verifying inbound HTTP callbacks from GStable is an application responsibility (use your stack’s crypto and the signing rules in the API docs).
Requirements
| Requirement | Detail |
|---|---|
| Node.js | ≥ 18 (global fetch). |
| API key | Secret key from the dashboard; never commit to git. |
Source of truth
- Request/response field definitions — API documentation.
- Method ↔ path mapping — Client overview and the resource pages under API reference.
Next steps
- Quick start — minimal runnable example.
- Installation — package managers, ESM/CJS, TypeScript.
- Client configuration —
baseUrl,publicBaseUrl, debug flag.