Reseller API v1
Integrate your site or app with Data2Buy. Use your API key to check balance, list bundles, create orders, and manage order history.
Base URL & Authentication
All requests go to:
https://data2buy.com/api/v1
You must send your API key on every request. Use one of these methods:
- Header:
X-API-Key: your_api_key - Header:
Authorization: Bearer your_api_key
Generate your API key from the Reseller Dashboard (API Access section). Keep it secret.
Check balance
Returns your current wallet balance (GHS). Use this before creating orders to ensure sufficient funds.
Response (200)
{
"balance": 150.50,
"currency": "GHS"
}
Example: cURL
curl -X GET "https://data2buy.com/api/v1/balance" \
-H "X-API-Key: your_api_key" \
-H "Accept: application/json"
Example: JavaScript (fetch)
const response = await fetch('https://data2buy.com/api/v1/balance', {
headers: {
'X-API-Key': 'your_api_key',
'Accept': 'application/json'
}
});
const data = await response.json();
console.log(data.balance); // 150.50
Example: PHP
$ch = curl_init('https://data2buy.com/api/v1/balance');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-API-Key: your_api_key',
'Accept: application/json'
]
]);
$body = curl_exec($ch);
$data = json_decode($body, true);
echo $data['balance']; // 150.50
List bundles
Returns all data bundles (all providers: MTN, Telecel, AirtelTigo, YELLO) with your reseller price. Use the id or network + volume when creating orders.
Response (200)
{
"bundles": [
{
"id": 1,
"network": "MTN",
"volume_gb": "1 GB",
"volume": 1,
"price": 4.50,
"currency": "GHS"
},
{
"id": 2,
"network": "MTN",
"volume_gb": "2 GB",
"volume": 2,
"price": 8.00,
"currency": "GHS"
}
]
}
Example: cURL
curl -X GET "https://data2buy.com/api/v1/bundles" \
-H "X-API-Key: your_api_key" \
-H "Accept: application/json"
Create order
Create a single data order. The cost is deducted from your wallet. Beneficiary must be a valid Ghana number (e.g. 0551234567).
Request body (JSON)
Option A — by package ID:
{
"package_id": 1,
"beneficiary": "0551234567"
}
Option B — by network and volume (GB):
{
"network": "MTN",
"volume": 1,
"beneficiary": "0551234567"
}
Response (201)
{
"reference": "API-67890ABCDEF",
"status": "processing",
"amount": 4.50,
"message": "Order sent to provider."
}
If the provider is set to Manual, status will be pending and message will indicate the order will be processed shortly.
Example: cURL
curl -X POST "https://data2buy.com/api/v1/order" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"package_id": 1, "beneficiary": "0551234567"}'
Example: JavaScript
const response = await fetch('https://data2buy.com/api/v1/order', {
method: 'POST',
headers: {
'X-API-Key': 'your_api_key',
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
package_id: 1,
beneficiary: '0551234567'
})
});
const data = await response.json();
console.log(data.reference); // API-67890ABCDEF
Bulk orders
Create multiple orders for the same package. Each beneficiary is charged from your balance. Invalid numbers are skipped and reported in the response.
Request body (JSON)
{
"package_id": 1,
"beneficiaries": ["0551234567", "0241234567", "0201234567"]
}
Response (201)
{
"message": "3 order(s) created.",
"success_count": 3,
"failed_count": 0,
"orders": [
{ "beneficiary": "0551234567", "reference": "API-xxx1", "status": "processing" },
{ "beneficiary": "0241234567", "reference": "API-xxx2", "status": "processing" },
{ "beneficiary": "0201234567", "reference": "API-xxx3", "status": "processing" }
]
}
Example: cURL
curl -X POST "https://data2buy.com/api/v1/orders/bulk" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{"package_id": 1, "beneficiaries": ["0551234567", "0241234567"]}'
Order status
Get details of a single order by reference or id. Query params: reference=API-xxx or id=123.
Response (200)
{
"id": 456,
"reference": "API-67890ABCDEF",
"network": "MTN",
"data_plan": "1 GB",
"beneficiary": "0551234567",
"amount": 4.50,
"status": "delivered",
"transaction_id": "ORD-12345",
"failure_reason": null,
"created_at": "2026-02-18T10:30:00.000000Z",
"updated_at": "2026-02-18T10:35:00.000000Z"
}
Status values: pending, processing, delivered, failed.
Example: cURL
curl -X GET "https://data2buy.com/api/v1/order?reference=API-67890ABCDEF" \
-H "X-API-Key: your_api_key"
Order history
Paginated list of your orders. Query params: per_page (1–100, default 20), page, status (pending, processing, delivered, failed), reference (partial match).
Response (200)
{
"data": [
{
"id": 456,
"reference": "API-67890ABCDEF",
"network": "MTN",
"data_plan": "1 GB",
"beneficiary": "0551234567",
"amount": 4.50,
"status": "delivered",
"transaction_id": "ORD-12345",
"failure_reason": null,
"created_at": "2026-02-18T10:30:00.000000Z",
"updated_at": "2026-02-18T10:35:00.000000Z"
}
],
"current_page": 1,
"last_page": 5,
"per_page": 20,
"total": 98
}
Example: cURL
curl -X GET "https://data2buy.com/api/v1/orders?per_page=10&status=delivered" \
-H "X-API-Key: your_api_key"
Error responses
Failed requests return JSON with an error message and an HTTP status code:
- 401 — Missing or invalid API key.
- 402 — Insufficient balance when creating an order.
- 403 — API key not for an approved reseller.
- 404 — Package or order not found.
- 422 — Validation error (e.g. invalid beneficiary number, missing fields).
{
"error": "Insufficient balance. Need 10.50 GHS."
}
Reseller API v1 — Data2Buy. Generate your API key from the Reseller Dashboard.