Node.js SDK
The @sanghosdk/js SDK is the official Sangho client for
Node.js 18+. It supports both ESM and CommonJS and is optimized for
server environments, Edge Functions, and serverless.
Installation
Available modules
The SDK is fully typed. Interfaces are exported directly — import PaymentIntent, Customer, ListResponse, etc. from @sanghosdk/js with no additional configuration.
Initialization
Error handling
All errors thrown by the SDK inherit from SanghoError, which
exposes type (category, e.g. VALIDATION_ERROR)
and code (precise business code, e.g. AMOUNT_TOO_SMALL —
see the full list). Use instanceof to differentiate business cases.
Pagination
List endpoints return a ListResponse<T> object with
fields count, next, previous, and data. Use the page and page_size parameters to
navigate.
The SDK automatically retries 429 (rate limit, honoring the
server’s Retry-After) and 5xx errors,
as well as genuine network failures, with exponential backoff. Remaining 4xx errors
(400, 401, 403, 404, 409, 422) are never retried — they are request
problems to fix, not transient incidents. Configure maxRetries at initialization (default: 3).