Data Purchase Endpoint
Endpoint
URL: /api/dataapi
Methods: POST, GET
Description
This API endpoint allows users to purchase mobile data for mobile phones and other internet enabled devices.
Authentication
To access this endpoint, users must include their API key and secret key in the request headers.
Request Headers
- api-key (string, required): The API key of the user.
- secret-key (string, required): The secret key of the user.
Request Body (POST)
- phone (string, required): The phone number to recharge.
- firstLevel (string, required): The network of data to purchase.
- secondLevel (string, required): The data plan to purchase.
Usage Example
See usage example in the code snippets below:
Example: Purchase Data
POST request to purchase data:
Content-Type: application/json
api-key: your-api-key
secret-key: your-secret-key
{
"phone": "08032566178",
"firstLevel": "MTN SME",
"secondLevel": "1GB"
}
Response:
- Status Code: 200
{
"message": "Transaction successful",
"data": {
"transactionId": "1234567890",
"email": "user@example.com",
"activity": "MTN SME",
"message": "1GB",
"status": "Successful",
"recipient": "08032566178",
"amount": 240,
"initialBalance": 500,
"finalBalance": 260,
"Method": API,
}
}
Failed Response Format
{
"error": "Transaction failed",
"data": {
"transactionId": "1234567890",
"email": "user@example.com",
"activity": "MTN SME",
"message": "1GB",
"status": "Failed",
"recipient": "08032566178",
"amount": 240,
"initialBalance": 500,
"finalBalance": 500
"Method": API,
}
}
GET request
See usage example in the code snippets below:
Get the list of available firstLevel and secondLevel
GET request for available firstLevel and secondLevel:
Content-Type: application/json
api-key: your-api-key
secret-key: your-secret-key
Response:
- Status Code: 200
"MTN SME": {
"available": true,
"secondLevel": [
"500MB",
"1GB",
"2GB",
"3GB"
],
"amount": [
120,
240,
480,
720
]
},
"MTN CG": {
"available": true,
"secondLevel": [
"500MB",
"1GB",
"2GB",
"3GB",
"5GB",
"10GB"
],
"amount": [
130,
275,
565,
855,
1435,
2885
]
}
}
Other Error Responses
- 401 Unauthorized: Invalid API key or secret key.
- 404 Not Found: User not found or data not available.
- 500 Internal Server Error: Internal server error occurred.