Afriex SDK
API Reference

API Reference

The Afriex SDK maps directly to the Afriex Business API.

Services

ServiceDescription
CustomersCreate and manage customers with KYC
TransactionsCreate and track money transfers
Payment MethodsManage payment methods, virtual accounts, crypto wallets
CheckoutCreate hosted payment sessions
BalanceGet wallet balances
RatesGet exchange rates
WebhooksVerify signatures, trigger test events

Authentication

Pass your API key during initialization:

const afriex = new AfriexSDK({
  apiKey: "your-api-key",
});

Error Handling

The SDK throws typed errors:

import { AfriexSDK, ApiError, ValidationError, NetworkError } from '@afriex/sdk';

try {
  await afriex.customers.create({ ... });
} catch (error) {
  if (error instanceof ValidationError) {
    // Missing or invalid required fields
    console.log('Validation failed:', error.errors);
  } else if (error instanceof ApiError) {
    // HTTP 4xx/5xx from API
    console.log('API error:', error.statusCode, error.message);
  } else if (error instanceof NetworkError) {
    // Network timeout or unreachable
    console.log('Network error:', error.message);
  }
}

On this page