Skip to main content

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 except Quote a Withdrawal, which you call over REST. The TypeScript snippet for each method appears as a tab in the right-hand code panel on that endpoint’s page. These docs describe @afriex/sdk 5.x. This page covers what is SDK-specific: install, init, configuration, retries, environments, and webhook signature handling.

Installation

Quick Start

1. Initialize the SDK

environment defaults to 'production'. A client created without it sends every request to production, so set it explicitly. The SDK’s name for the sandbox is 'staging', which points at https://sandbox.api.afriex.com, the same sandbox the rest of these docs describe.

2. Make your first calls

For the full set of methods, browse the API reference; each endpoint page shows the equivalent SDK call.

Configuration

Enable Retries

Retries are disabled by default. Enable them with retryConfig. The SDK retries a request when it fails with one of retryableStatusCodes:
POST and PATCH are not retried by default, because sending one twice can repeat its effect. So transactions.create is not retried even with retryConfig set. A transaction create is safe to send again with the same meta.idempotencyKey (see Idempotency), so retry it yourself, or add "POST" to retryConfig.retryableMethods. That list applies to every endpoint, and other creates, such as payment methods, have no idempotency key. A retry resends the same body, so it carries the same idempotency key. If a retried create returns 409 DUPLICATE_REQUEST, the first attempt went through: look the transaction up by its reference instead of sending it again.

Environments

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.

Credits

The SDK started as a hackathon project by the Afriex DevRel team and is now maintained as the official SDK.