Skip to main content
This SDK was built by the Afriex DevRel team, winners of our hackathon. We loved what they built so much that it became the official SDK. Big shoutout to the team for making this happen.

Overview

The Afriex SDK is a TypeScript library that wraps the Afriex Business API with full type definitions, built-in retry logic, and modular imports. Every REST endpoint in the API reference has a matching SDK method; the TypeScript snippet appears as a tab in the right-hand code panel on each endpoint page. This page covers what is SDK-specific: install, init, configuration, retries, environments, and webhook signature handling.

Installation

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

Quick Start

1. Initialize the SDK

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

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

2. Make your first calls

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

const rates = await afriex.rates.getRates({
  fromSymbols: "USD",
  toSymbols: "NGN,GBP",
});

const balances = await afriex.balance.getBalance({
  currencies: ["USD", "NGN"],
});
For the full set of methods, browse the API reference; each endpoint page shows the equivalent SDK call.

Configuration

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

Enable Retries

Retries are disabled by default. Enable them with retryConfig:
const afriex = new AfriexSDK({
  apiKey: process.env.AFRIEX_API_KEY,
  retryConfig: {
    maxRetries: 3,
    retryDelay: 1000,
    retryableStatusCodes: [408, 429, 500, 502, 503, 504],
  },
});

Environments

EnvironmentBase URL
Staginghttps://sandbox.api.afriex.com
Productionhttps://api.afriex.com
Get your API key from the Afriex Dashboard under the Developer tab.

Webhooks

The SDK ships helpers for verifying webhook signatures and parsing event payloads. See Webhooks.