Afriex SDK

Getting Started

Prerequisites

Installation

npm install @afriex/sdk
# or
pnpm add @afriex/sdk
# or
yarn add @afriex/sdk

Quick Start

1. Import and initialize

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

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

2. Make requests

// Create customer
const customer = await afriex.customers.create({
  fullName: "John Doe",
  email: "john@example.com",
  phone: "+1234567890",
  countryCode: "US",
});

// Check balance
const balances = await afriex.balance.getBalance({
  currencies: ["USD", "NGN"],
});

console.log("Customer:", customer);
console.log("Balances:", balances);

Configuration

OptionTypeDefaultDescription
apiKeystringRequiredYour Afriex API key
environmentstring'production''staging' or 'production'
webhookPublicKeystring-Public key for webhook verification
retryConfigRetryConfig{ maxRetries: 0 }Request retry configuration

Enable Retries

Retries are disabled by default. Enable them:

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

Environments

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

On this page