npm install @afriex/sdk
# or
pnpm add @afriex/sdk
# or
yarn add @afriex/sdk
import { AfriexSDK, Environment } from "@afriex/sdk";
const afriex = new AfriexSDK({
apiKey: process.env.AFRIEX_API_KEY,
environment: "staging", // or 'production'
});
// 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);
| Option | Type | Default | Description |
|---|
apiKey | string | Required | Your Afriex API key |
environment | string | 'production' | 'staging' or 'production' |
webhookPublicKey | string | - | Public key for webhook verification |
retryConfig | RetryConfig | { maxRetries: 0 } | Request retry configuration |
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],
},
});
| Environment | URL |
|---|
| Staging | https://sandbox.api.afriex.com |
| Production | https://api.afriex.com |