Server API MAGS
š” MidnightStreamer Pro API ā Managing MAG Devices via Server API
MidnightStreamer Pro offers full control over MAG devices (Stalker/Portal compatible) via a secure and powerful Server API. This guide shows you how to create, edit, delete, and retrieve MAG device data remotely using authenticated HTTP POST requests.
š Create a New MAG Device
Endpoint:
http://your-domain:8000/api/mag/new
Required Parameter:
mac_address
Example PHP Code:
$panel_url = 'http://your-domain:8000/';
$api_key = 'your_api_key';
$mac_address = '00:1A:79:79:79:79';
$subscription_plan = 1;
$expire_date = strtotime("+1 month");
$post_data = array(
'api_key' => $api_key,
'data' => array(
'mac_address' => $mac_address,
'expire_date' => $expire_date,
'subscription_plan_id' => $subscription_plan
)
);
$opts = array('http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query($post_data)
));
$context = stream_context_create($opts);
$api_result = json_decode(file_get_contents($panel_url . "api/mag/new", false, $context));
print_r($api_result);
ā Success Response:
{"result":true}
ā Failure Response:
{"result":false,"error":"MAC Address already exists"}
āļø Edit a MAG Device
Endpoint:
http://your-domain:8000/api/mag/update
Required:
mac_address
$post_data = array(
'api_key' => $api_key,
'mac_address' => $mac_address,
'data' => array(
'expire_date' => strtotime("+1 month"),
'subscription_plan_id' => 1
)
);
ā Success:
{"result":true}
ā Errors:
{"result":false,"error":"Invalid MAC Address"}
All database errors are logged under LOGS ā Panel Error Log
ā Delete a MAG Device
Endpoint:
http://your-domain:8000/api/mag/delete
Required Parameter:
mac_address
This will permanently remove the MAG device from the system.
š View MAG Device Info
Endpoint:
http://your-domain:8000/api/mag/info
Required Parameter:
mac_address
Example Code:
$panel_url = 'http://your-domain:8000/';
$api_key = 'your_api_key';
$mac_address = '00:1A:79:79:79:79';
$post_data = array(
'api_key' => $api_key,
'mac_address' => $mac_address
);
$opts = array('http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query($post_data)
));
$context = stream_context_create($opts);
$api_result = json_decode(file_get_contents($panel_url . "api/mag/info", false, $context), true);
if ($api_result['result']) {
echo "MAG Connections: " . json_encode($api_result['conn_info']);
echo "\nCurrent Expire Date: " . (empty($api_result['info']['expire_date']) ? 'Unlimited' : $api_result['info']['expire_date']);
echo "\nMax Connections: " . $api_result['info']['max_allowed_connections'];
echo "\nAvailable Channel IDs: " . implode(',', $api_result['channel_ids']);
} else {
echo 'FAILED';
}
š MAG Device API Overview
Operation | Endpoint | Required Param | Method |
---|---|---|---|
Create MAG | /api/mag/new |
mac_address | POST |
Edit MAG | /api/mag/update |
mac_address | POST |
Delete MAG | /api/mag/delete |
mac_address | POST |
View MAG Info | /api/mag/info |
mac_address | POST |