Server Api Mags
Learn how to create, edit, delete and retrieve MAG device data using the MidnightStreamer Pro Server API.
📡 MidnightStreamer Pro API – MAG Device Management
MidnightStreamer Pro provides full control over MAG devices through its Server API. You can create, update, delete and retrieve MAG device information using authenticated 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
Example PHP Code:
$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}
Error:
{"result":false,"error":"Invalid MAC Address"}
All errors are logged under LOGS → Panel Error Log.
❌ Delete a MAG Device
Endpoint:
http://your-domain:8000/api/mag/delete
Required: mac_address
This action removes the device permanently.
🔍 View MAG Device Info
Endpoint:
http://your-domain:8000/api/mag/info
Required: mac_address
Example:
$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 |
This guide covers all operations needed to manage MAG devices using the MidnightStreamer Pro API.