Skip to main content

Node.js Examples

Complete Node.js example client for integrating with the 123hub API using the built-in crypto module and native fetch.
This is a reference implementation, not an official SDK package. It uses only Node.js built-in modules (no external dependencies required). Requires Node.js 18+ for native fetch.

Configuration

Store your credentials in environment variables:

PaymentApiClient Class (JavaScript)

PaymentApiClient Class (TypeScript)

Usage Examples

Ping (Health Check)

Create a Deposit Payment

The examples below use INR (India), but the same client works for every supported country — just change the serviceId, currency, and country values.

Create a Withdrawal (Payout)

Check Payment Status

Get Balance

Error Handling

Successful responses return HTTP 200. Most errors return HTTP 400; some use 403, 404, 409, 429 or 5xx (see Error codes). The client returns the parsed body for every standard envelope, so always use the success field to determine the outcome:

Handling Network Errors

Network-level errors can still occur independently of API responses:

Complete Example