Skip to Content
Getting Started

Getting Started

Prerequisites

Before using the Afriex SDK, ensure you have:

  • Node.js installed (v20 or later)
  • A valid Afriex API Key (contact support to obtain one)

Installation

Install the package via your preferred package manager:

npm install @afriex/sdk

Basic Usage

1. Import the SDK

import { AfriexSDK, Environment } from "@afriex/sdk";

2. Initialize the client

const afriex = new AfriexSDK({ apiKey: process.env.AFRIEX_API_KEY, environment: "staging", // 'staging' or 'production' });

3. Make a request

// Create a customer const customer = await afriex.customers.create({ fullName: "John Doe", email: "john@example.com", phone: "+1234567890", countryCode: "US", }); // Get balance const balances = await afriex.balance.getBalance({ currencies: ["USD", "NGN"], }); console.log("Customer:", customer); console.log("Balances:", balances);

Configuration Options

OptionTypeDefaultDescription
apiKeystringRequiredYour Afriex API key.
environmentstring'production'Target environment ('staging' or 'production').
webhookPublicKeystring-Afriex public key for webhook verification.
retryConfigRetryConfig{ maxRetries: 0 }Configuration for request retries.

Retry Configuration

By default, retries are disabled. You can enable them by passing a retryConfig:

const afriex = new AfriexSDK({ apiKey: "...", retryConfig: { maxRetries: 3, retryDelay: 1000, // 1 second retryableStatusCodes: [408, 429, 500, 502, 503, 504], }, });

Server URLs

EnvironmentURL
Staginghttps://sandbox.api.afriex.com
Productionhttps://api.afriex.com