How to Integrate a VTU API (PHP & Python)
Step-by-step code samples to automate data bundle purchases and airtime top-ups in your web or mobile applications.
1. PHP cURL Integration Example
<?php
$apiKey = "YOUR_SECRET_API_KEY";
$url = "https://babspay.com.ng/api/data";
$payload = [
"network" => 1,
"plan" => 223,
"mobile_number" => "08137000125",
"Ported_number" => true
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer {$apiKey}",
"Content-Type: application/json",
"Accept: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if ($result['status'] === 'success') {
echo "Data purchased! Ref: " . $result['transaction_id'];
}
?>
2. Python Requests Integration Example
import requests
API_KEY = "YOUR_SECRET_API_KEY"
URL = "https://babspay.com.ng/api/data"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
data = {
"network": 1,
"plan": 223,
"mobile_number": "08137000125",
"Ported_number": True
}
response = requests.post(URL, json=data, headers=headers)
res_json = response.json()
if res_json.get("status") == "success":
print(f"Data Delivered: {res_json.get('transaction_id')}")
Get Your Free API Key
Sign up on BABSPAY, visit your dashboard, and generate instant API credentials.
Register Developer Account