GN DATA
Developer Portal v1.0

GN Data API Documentation

Automate Airtime recharge, Data bundle top-ups, Cable TV renewals, and Electricity utility payments via clean, high-performance RESTful endpoints.

Base URL http://localhost:8002/api/v1

Getting Started

Follow these simple steps to become an API user and start integrating GN Data services into your application:

1

Register Account

Create a user account on the GN Data website/app.

2

Self-Service Upgrade

Open your Profile or Developer Dashboard, fill out the quick activation form, and accept the API Terms of Service.

3

Generate API Key

Access your Developer API Settings dashboard to generate your Authorization: Bearer <API_KEY> token.

4

Start Requesting

Call our endpoints with your API Key to automate airtime, data, cable, and electricity transactions.

Instant Self-Service API Activation: Developer accounts are completely self-service! You do not need to contact customer support to activate API access. Simply navigate to Profile → Become an API User on the web or mobile app, complete the activation form, accept our API Terms of Service, and your account will be upgraded immediately.

Authentication & Headers

GN Data uses standard Bearer token authorization. Pass your API Key in the HTTP Authorization header.

Auto-Detection: The API backend automatically detects whether your Bearer token is a Developer API Key or a User JWT Token. No 4-digit transaction PIN is required for developer API requests.

Required Request Headers

Header Name Type Description
Authorization String REQUIRED Bearer <YOUR_API_KEY>
Content-Type String REQUIRED Must be application/json.

Sandbox Testing & Simulation

Test your integrations safely without debiting real funds or calling external telecom providers.

Sandbox Mode Distinction: Sandbox requests are distinguished by the secret key prefix. Pass a Sandbox API Secret Key with the gndk_test_ prefix in your Authorization: Bearer <key> header. All requests will automatically operate against your dedicated Sandbox Wallet Balance (starting with ₦20,000.00 from config) and record isolated SandboxWalletTransaction entries.

Target Phone / Meter Simulation Numbers

Specify any of the following phone/target numbers in your purchase requests to stimulate specific transaction states:

Target / Phone Number Simulated Result Behavior & Ledger Impact
08000000000, 08022222222, 08000000002, or any number ending in 0000 FAILED (HTTP 400) Simulates a provider failure. Debited funds are automatically refunded to your Sandbox balance.
08011111111, 08033333333, 08000000001, or any number ending in 1111 PENDING Simulates a pending transaction. Funds remain debited, and status is recorded as pending.
Any other valid Nigerian number (e.g. 08012345678) SUCCESS (HTTP 200) Simulates immediate successful delivery. Generates realistic prepaid tokens for electricity and debits sandbox balance.

Idempotency & Replay Protection

Learn how the idempotency key protects your wallet balance from accidental double-debits and guarantees safe API retries during network interruptions.

What is an Idempotency Key? An idempotency key is a unique client-generated token (recommended format: UUID v4) that identifies a specific purchase request. It guarantees that state-changing operations (such as purchasing airtime, data bundles, cable TV subscriptions, or electricity tokens) are executed safely at most once, even if network timeouts or dropped connections cause the same request to be sent repeatedly.
1

Generate Unique Key

Generate a fresh UUID v4 on your system for each new purchase intent. Pass it in your JSON request body as idempotency_key.

2

Execute Safely

On the first request, our engine acquires an atomic lock, debits your wallet, submits the order to the telecom or utility provider, and stores the transaction record.

3

Replay Returns First Record

If the same idempotency key is sent again, your wallet is never debited a second time. The API immediately returns the original transaction record from the first call.

When & How to Use the Idempotency Key

Scenario Client Action Engine Behavior & Wallet Safety
Brand New Purchase
Customer taps Pay or Checkout
Generate a new, unique UUID v4 (e.g. 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d) and store it with your local order. Processes transaction normally: checks wallet balance, debits wallet atomically, places upstream order, and logs transaction.
Network Timeout or Dropped Connection (HTTP 504)
Client timed out waiting for server response
Reuse the exact same idempotency key when retrying the request. Do NOT generate a new key for retries. Zero duplicate charge guarantee: If the original transaction was already completed, the API returns the original transaction record without debiting your wallet again.
Concurrent In-Flight Duplicate (HTTP 409)
Rapid duplicate call while first is processing
If your client sends duplicate calls simultaneously, the server responds with 409 Conflict. Await the initial call or query status via GET /api/v1/transactions/{request_id}. Protects against race conditions and concurrent double-debits while an advisory lock is held for the first request.
Important Replay Behavior: When a request with an existing idempotency_key is received, the API will not re-charge your wallet or re-order from the provider. Instead, it directly returns the transaction record of the first request (including original request_id, transaction_id, amount, status, and phone) with HTTP 200 OK.

Passing idempotency_key in Request Body

JSON REQUEST PAYLOAD
{
  "phone": "08012345678",
  "network_id": 1,
  "plan_id": 10,
  "idempotency_key": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
}

Response on Replay (Returns First Transaction Record)

HTTP 200 OK (FIRST TRANSACTION RECORD RETURNED)
{
  "request_id": "2026111714300012345",
  "status": "success",
  "amount": 285.0,
  "phone": "08012345678",
  "network_id": 1,
  "plan_id": 10,
  "transaction_id": "tx_2026111714300012345",
  "message": "Data purchase: MTN - 08012345678"
}

Notice that the response contains the exact transaction record and reference of the original attempt. Your wallet is not charged again.

GET /api/v1/wallet/balance Get User Balance

Fetch your current wallet balance, currency, user ID, email, and virtual account funding details.

Headers Required

Authorization Bearer <API_KEY>
SAMPLE RESPONSE (200 OK)
{
  "balance": 15450.00,
  "currency": "NGN",
  "user_id": 42,
  "email": "developer@example.com",
  "account_numbers": [
    {
      "bank_name": "Palmpay",
      "account_number": "9912345678",
      "account_name": "GNDATA-Ganiu",
      "provider": "paymentpoint"
    }
  ]
}
GET /api/v1/transactions List & Filter Transactions

Retrieve your transaction ledger history. Filter by status (such as pending, success, failed), service category, recipient phone/meter number, or search query.

Query Parameters

Parameter Type Description
status String Filter by transaction status: pending, success, failed, refund.
category String Filter by category: data_purchase, airtime_purchase, tv_purchase, electricity_purchase, funding.
search String Search by request ID, reference, phone number, meter number, or description.
skip Integer Number of records to skip (default: 0).
limit Integer Maximum records to return (default: 50, max: 100).
SAMPLE RESPONSE (200 OK)
[
  {
    "id": 1052,
    "request_id": "GND_DATA_20261102_99182",
    "reference": "GND_DATA_20261102_99182",
    "amount": 270.0,
    "balance_before": 15450.0,
    "balance_after": 15180.0,
    "transaction_type": "debit",
    "category": "data_purchase",
    "status": "success",
    "target": "08031234567",
    "item_name": "MTN - 1.0GB SME - 30 Days",
    "description": "Data purchase: MTN - 08031234567",
    "purchased_code": null,
    "time_created": "2026-11-02T16:15:30Z",
    "time_updated": "2026-11-02T16:15:32Z"
  }
]
GET /api/v1/transactions/{request_id} Query Transaction Status

Query the status and full details of any transaction using its request_id.

Automatic Pending Transaction Resolution: If a transaction is currently in pending status (e.g., following a network timeout or gateway delay), calling this endpoint triggers an active requery and synchronization check against the provider. If the transaction completed, the status is updated to success (with tokens or recharge pins if applicable). If the provider indicates failure, the transaction is marked failed and your debited wallet balance is restored immediately.

Path Parameters

Parameter Type Description
request_id String REQ The unique request ID returned when the transaction was initiated (e.g. GND_AIR_20260814_10293).

Possible Status Values

success Transaction completed and value delivered.
pending Transaction is still being processed. Check again in a few moments or await webhook.
failed Transaction failed; wallet funds have been refunded.
refund Transaction was refunded by administrator.
SAMPLE RESPONSE (200 OK)
{
  "id": 1053,
  "request_id": "GND_ELEC_20261102_77192",
  "reference": "GND_ELEC_20261102_77192",
  "amount": 2000.0,
  "balance_before": 15180.0,
  "balance_after": 13180.0,
  "transaction_type": "debit",
  "category": "electricity_purchase",
  "status": "success",
  "target": "10101234567",
  "item_name": "IKEDC - Prepaid",
  "description": "Electricity purchase: IKEDC - 10101234567",
  "purchased_code": "4920-1928-1029-4820-1920",
  "time_created": "2026-11-02T16:20:00Z",
  "time_updated": "2026-11-02T16:20:05Z"
}
GET /api/v1/airtime/services List Airtime Networks

Retrieve all available airtime network providers along with network ID, name, limits, and reseller commission rates.

SAMPLE RESPONSE (200 OK)
[
  {
    "id": 1,
    "name": "MTN Airtime",
    "image_url": "https://api.gndata.com.ng/static/mtn.png",
    "minimum_amount": 50.0,
    "maximum_amount": 50000.0,
    "available": true,
    "reseller_commission_rate": 2.0
  }
]
POST /api/v1/airtime/purchase Purchase Airtime

Instant airtime recharge to any phone number using the Network ID.

Request Payload Parameters

Field Type Description
phone String REQ Recipient phone number (e.g. 08031234567).
amount Integer REQ Recharge amount in NGN (e.g. 500).
id Integer REQ Network database ID (e.g. 1 for MTN).
idempotency_key String REQ Unique UUID string per purchase request to prevent accidental duplicate debits. See guide →
REQUEST BODY (JSON)
{
  "phone": "08031234567",
  "amount": 500,
  "id": 1,
  "idempotency_key": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
}
RESPONSE (200 OK)
{
  "request_id": "GND_AIR_20260814_10293",
  "status": "success",
  "cost": 490.0,
  "phone": "08031234567",
  "transaction_id": "TX_9981240",
  "message": "Airtime recharge successful"
}
GET /api/v1/data/services List Data Networks

Fetch active data network providers. Pass ?include_plans=true query parameter to nest all available data plans inside each network object.

SAMPLE RESPONSE (200 OK)
[
  {
    "id": 1,
    "name": "MTN Data",
    "image_url": "https://api.gndata.com.ng/static/mtn.png",
    "minimum_amount": 0.0,
    "maximum_amount": 50000.0,
    "available": true,
    "plans": null
  }
]
GET /api/v1/data/plans/{network_id} Get Data Plans for Network

Retrieve all active data plans for a specific network ID (e.g. network_id = 1 for MTN Data). Prices returned reflect your developer API user rate.

SAMPLE RESPONSE (200 OK)
[
  {
    "id": 10,
    "name": "MTN SME 1GB - 30 Days",
    "network_id": 1,
    "price": 265.0,
    "duration": "Monthly",
    "validity": "30days",
    "type": "SME",
    "total_data": "1GB",
    "available": true
  }
]
POST /api/v1/data/purchase Purchase Data Bundle

Instant data bundle top-up for a specified phone number using network_id and plan_id.

Request Payload Parameters

Field Type Description
phone String REQ Recipient phone number.
network_id Integer REQ Network ID (e.g. 1 for MTN).
plan_id Integer REQ Data plan ID (e.g. 10).
idempotency_key String REQ Unique UUID string per purchase request to prevent accidental duplicate debits. See guide →
REQUEST BODY (JSON)
{
  "phone": "08031234567",
  "network_id": 1,
  "plan_id": 10,
  "idempotency_key": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
}
RESPONSE (200 OK)
{
  "request_id": "GND_DATA_20260814_99214",
  "status": "success",
  "amount": 265.0,
  "phone": "08031234567",
  "network_id": 1,
  "plan_id": 10,
  "transaction_id": "TX_8812903",
  "message": "Data purchase successful"
}

Cable TV Subscriptions

POST /api/v1/tv/verify Verify Smartcard / IUC Number

Verify customer details before subscribing to DSTV, GOTV, Startimes, or Showmax.

Field Type Description
billers_code String REQ Smartcard or IUC number.
service_id String REQ dstv, gotv, startimes, or showmax.
REQUEST BODY
{
  "billers_code": "7012345678",
  "service_id": "gotv"
}
RESPONSE (200 OK)
{
  "customer_name": "JOHN DOE",
  "customer_number": "7012345678",
  "status": "Open",
  "due_date": "2026-09-01",
  "balance": "0.00"
}
POST /api/v1/tv/purchase Subscribe Cable TV

Purchase or renew TV subscription packages.

Field Type Description
billers_code String REQ Smartcard or IUC number.
service_id String REQ dstv, gotv, startimes, etc.
variation_code String REQ Package variation code (e.g. gotv-jolli).
amount Integer REQ Package price.
phone String REQ Customer phone number.
idempotency_key String REQ Unique UUID string per purchase request to prevent accidental duplicate debits. See guide →
REQUEST BODY
{
  "billers_code": "7012345678",
  "service_id": "gotv",
  "variation_code": "gotv-jolli",
  "amount": 3950,
  "phone": "08031234567",
  "idempotency_key": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
}

Electricity Utility Bills

POST /api/v1/electricity/verify Verify Meter Number

Verify Prepaid or Postpaid meter number to retrieve customer name & address.

Field Type Description
billers_code String REQ Meter number (e.g. 1111111111111).
service_id String REQ DISCO service code (e.g. ikeja-electric).
type String REQ prepaid or postpaid.
REQUEST BODY
{
  "billers_code": "1111111111111",
  "service_id": "ikeja-electric",
  "type": "prepaid"
}
RESPONSE (200 OK)
{
  "customer_name": "JANE DOE",
  "address": "12 ALLEN AVENUE, IKEJA",
  "status": "Open",
  "customer_number": "1111111111111"
}
POST /api/v1/electricity/purchase Buy Electricity Token

Purchase electricity tokens for prepaid meters or pay postpaid bills.

Field Type Description
billers_code String REQ Meter number.
service_id String REQ DISCO service code (e.g. ikeja-electric).
variation_code String REQ prepaid or postpaid.
amount Integer REQ Amount in NGN.
phone String REQ Recipient phone number.
idempotency_key String REQ Unique UUID string per purchase request to prevent accidental duplicate debits. See guide →
REQUEST BODY (JSON)
{
  "billers_code": "10001234567",
  "service_id": "ikeja-electric",
  "variation_code": "prepaid",
  "amount": 2000,
  "phone": "08031234567",
  "idempotency_key": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
}
RESPONSE (200 OK)
{
  "request_id": "GND_ELEC_20260814_88102",
  "status": "success",
  "amount": 2000.0,
  "phone": "08031234567",
  "service_id": "ikeja-electric",
  "variation_code": "prepaid",
  "purchased_code": "1234-5678-9012-3456-7890",
  "transaction_id": "TX_771920",
  "message": "Token generated successfully"
}

Webhooks & Event Notifications

Register your webhook callback URL in the Developer Dashboard to receive real-time HTTP POST notifications.

Synchronous Purchases: Purchase transactions (Airtime, Data, Cable TV, Electricity) execute synchronously with instant API responses. GN Data does not send webhooks for standard successful or failed purchase calls. A transaction webhook (transaction.refund) is dispatched only if an order is refunded back to your wallet.

🔐 Webhook Security & HMAC-SHA256 Signature (X-GN-Signature)

Every webhook sent by GN Data includes cryptographic headers so your application can verify its origin and guarantee body integrity:

  • X-GN-Signature: Hex-encoded HMAC-SHA256 signature of the raw request payload computed using your Webhook Secret (whsec_live_... or whsec_test_...).
  • X-GN-Timestamp: Unix epoch timestamp when the webhook was generated.
  • User-Agent: GNData-Webhook/1.0
VERIFICATION EXAMPLES
// Node.js (Express with raw body)
const crypto = require("crypto");

app.post("/webhook", express.raw({ type: "application/json" }), (req, res) => {
  const signature = req.headers["x-gn-signature"];
  const secret = process.env.GN_DATA_WEBHOOK_SECRET; // whsec_live_... or whsec_test_...
  const expectedSig = crypto.createHmac("sha256", secret).update(req.body).digest("hex");

  if (crypto.timingSafeEqual(Buffer.from(signature || ""), Buffer.from(expectedSig))) {
    const payload = JSON.parse(req.body.toString());
    // Handle event safely...
    return res.status(200).json({ status: "ok" });
  }
  return res.status(401).send("Invalid signature");
});

# Python (FastAPI / Flask)
import hmac, hashlib

def verify_webhook(raw_body: bytes, header_signature: str, secret: str) -> bool:
    expected = hmac.new(secret.encode("utf-8"), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, header_signature or "")

// PHP
$payload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_GN_SIGNATURE'] ?? '';
$secret = getenv('GN_DATA_WEBHOOK_SECRET');
$expectedSig = hash_hmac('sha256', $payload, $secret);

if (hash_equals($expectedSig, $signature)) {
    http_response_code(200);
} else {
    http_response_code(401);
}

1. Catalog & Pricing Synchronization (sync)

Fired when data plans, airtime networks, cable TV bouquets, or electricity discos catalog data or pricing is modified. The service_type field indicates which service catalog should be synchronized (e.g. data, airtime, cable, electricity) in case your application maintains local storage or cached variations.

SAMPLE WEBHOOK PAYLOAD (SYNC)
{
  "event": "sync",
  "service_type": "data",
  "timestamp": "2026-11-04T12:00:00Z"
}

2. Platform Broadcast Announcement (announcement.broadcast)

Fired when administrators broadcast maintenance alerts, telecom fluctuations, or service announcements.

SAMPLE WEBHOOK PAYLOAD (ANNOUNCEMENT)
{
  "event": "announcement.broadcast",
  "id": 15,
  "title": "MTN SME Network Maintenance",
  "message": "MTN is currently experiencing network fluctuations. Data delivery may be slightly delayed.",
  "type": "warning",
  "timestamp": "2026-11-04T07:15:00Z"
}

3. Transaction Refund (transaction.refund)

Fired when an order is refunded back to your wallet balance (for example, following manual admin reconciliation or upstream failure).

SAMPLE WEBHOOK PAYLOAD (REFUND)
{
  "event": "transaction.refund",
  "reference": "GND_DATA_20261104_10293",
  "category": "data_purchase",
  "target": "08031234567",
  "amount": 500.0,
  "refund_amount": 500.0,
  "new_wallet_balance": 15450.0,
  "status": "refund",
  "description": "Refund of ₦500.00 for transaction GND_DATA_20261104_10293.",
  "timestamp": "2026-11-04T14:10:00Z"
}

Standard HTTP Error Codes

Status Code Error Description Resolution
400 Bad Request Invalid request parameters or insufficient wallet balance. Check your request payload or fund your API wallet.
401 Unauthorized Missing or invalid Authorization: Bearer <API_KEY> header. Verify your API Key in the developer dashboard.
409 Conflict Duplicate idempotency_key in progress. See guide → Wait for initial transaction completion or use a new key.
504 Gateway Timeout Provider timeout during processing. Transaction is marked pending. Query GET /api/v1/transactions/{request_id} to requery or await automated webhook update.