Quick start
1. Install
npm install gstable-js
Package on npm: gstable-js.
2. Set your API key
Use an environment variable (recommended):
export GSTABLE_API_KEY="sk_live_xxxxxxxx"
In production, load secrets from your host’s secret manager or process env — never embed keys in source.
3. List accounts (authenticated)
import { GStableClient } from 'gstable-js';
const client = new GStableClient({
apiKey: process.env.GSTABLE_API_KEY,
});
const accounts = await client.account.list();
console.log(accounts);
account.list() resolves to the data array from the API response envelope (the SDK unwraps data for you).
4. Fetch public payment capabilities (no auth on wire)
const caps = await client.capability.all();
console.log(caps);
Although apiKey is required in the constructor (for private resources), capability.all() uses the public base URL and does not send Authorization for this request.
5. Handle errors
import { GStableClient, isGStableError } from 'gstable-js';
const client = new GStableClient({ apiKey: process.env.GSTABLE_API_KEY });
try {
await client.product.list(1, 20);
} catch (e) {
if (isGStableError(e)) {
console.error('GStable error', e.code, e.message);
}
throw e;
}
See Error codes & SDK exceptions.
6. Optional: debug outgoing requests
GSTABLE_DEBUG=1 node ./your-script.mjs
Logs method, URL, and headers (including Authorization) to console.error. Treat logs as sensitive.
Next steps
- Client configuration —
baseUrl,publicBaseUrl, customfetch. - Payment Links integration — end-to-end pattern.
- Webhooks — registering endpoints with the API.