API Reference
API Reference
The Afriex SDK maps directly to the Afriex Business API.
Services
| Service | Description |
|---|---|
| Customers | Create and manage customers with KYC |
| Transactions | Create and track money transfers |
| Payment Methods | Manage payment methods, virtual accounts, crypto wallets |
| Checkout | Create hosted payment sessions |
| Balance | Get wallet balances |
| Rates | Get exchange rates |
| Webhooks | Verify 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);
}
}