API Overview
The Data Purchase API allows you to programmatically purchase data plans for phone numbers. This is useful for applications that need to integrate data purchase functionality.
POST Base URL: https://mernoodatasub.com/api/buy_data.php
Authentication
This API uses Bearer Token authentication. You must include your API key in the Authorization header of each request.
Header Format
Authorization: Bearer YOUR_API_KEY
Note: Replace YOUR_API_KEY with your actual API key obtained from the main website.
API Endpoint
Purchase Data Plan
Purchase a data plan for a specified phone number.
POST Endpoint: /api/buy_data.php
Request Details
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Authorization | Bearer YOUR_API_KEY | Yes |
Request Body
{
"plan_id": "integer (required)",
"phone": "string (required)"
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| plan_id | integer | Yes | ID of the data plan to purchase |
| phone | string | Yes | Recipient phone number |
Response Details
Success Response (200 OK)
{
"status": "success",
"message": "Data purchase successful",
"data": {
"data_id": 12345,
"reference": "REF-123456",
"phone": "08012345678",
"plan": "1GB Monthly Plan",
"price": 500,
"provider_response": {
"status": true,
"message": "Data sent successfully"
}
}
}
Error Responses
Invalid API Key (403 Forbidden)
{
"status": "error",
"message": "Invalid API key"
}
Missing Parameters (400 Bad Request)
{
"status": "error",
"message": "plan_id and phone parameters are required"
}
Insufficient Balance (400 Bad Request)
{
"status": "error",
"message": "Insufficient balance. Please top up your API account"
}
Purchase Failed (400 Bad Request)
{
"status": "error",
"message": "Purchase failed: Provider error message",
"provider_response": {
"status": false,
"message": "Invalid phone number"
}
}
Error Codes
| HTTP Status | Description |
|---|---|
| 200 | Success |
| 400 | Bad Request (missing parameters, invalid data) |
| 401 | Unauthorized (API key missing) |
| 403 | Forbidden (invalid API key) |
| 405 | Method Not Allowed |
| 500 | Internal Server Error |
Getting Started
1. Obtain Your API Key
To use this API, you need an API key:
- Log in to your account on the main website
- Navigate to the API section
- Generate a new API key or use an existing one
2. View Available Data Plans
Please visit the main website to view all available data plans and their corresponding plan_id values.
3. Make Your First Request
Here's an example using cURL:
curl -X POST https://yourdomain.com/api/data-purchase \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"plan_id": 5,
"phone": "08012345678"
}'
Rate Limiting: Currently no rate limits are imposed, but we reserve the right to implement limits if necessary.