Mobile top-up API for Afghanistan, Pakistan, Algeria, Nigeria & Kenya — send airtime programmatically with 4 simple endpoints
# AFGTopup — API Integration Starter Kit
Node.js is provided as a reference implementation; the AFGTopup Partner API can be integrated from any backend technology capable of making HTTPS requests and handling JSON. Regardless of language, the same rules apply: keep the API key server-side only, use HTTPS, and generate a unique `external_id` per order.
A reference Node.js client for the AFGTopup Partner API — the API itself works with any backend that can make HTTPS requests.
Send mobile airtime top-ups to supported countries using a secure prepaid API account.
Currently supported countries:
- Afghanistan
- Pakistan
- Algeria
- Morocco
- Nigeria
- Kenya
---
# What's in this kit
| File | Purpose |
|------|---------|
| `afgtopup-client.js` | API client covering all 4 endpoints |
| `example.js` | Complete integration example |
| `.env.example` | Environment variable template |
| `README.md` | Integration documentation |
---
# Quick Start
## 1. Install dependencies
```bash
npm install
```
Node.js 18 or newer is recommended.
---
## 2. Configure your API key
Copy the example environment file:
```bash
cp .env.example .env
```
Open `.env` and add the API key provided by AFGTopup:
```env
AFGTOPUP_API_KEY=your_private_api_key_here
```
Do not put your real API key directly inside JavaScript code.
Do not commit your `.env` file to GitHub.
AFGTopup may rotate your credential before LIVE activation. When that happens, replace only the server-side environment variable; the API integration code and endpoint URLs stay the same.
---
## 3. Test the integration
Before running the example, open:
```text
example.js
```
and replace the example phone number with a phone number you are authorized to use for testing.
Then run:
```bash
node example.js
```
or:
```bash
npm test
```
Before Step 4, check your Partner Portal:
```text
afgtopup.com
```
If the portal shows **SANDBOX**, the top-up is simulated: no real mobile credit is sent and no p …