Server API Lines
š MidnightStreamer Pro API Guide ā Add, Edit, View & Delete Lines Programmatically
MidnightStreamer Pro includes a powerful Server API that allows you to create, edit, view, and delete IPTV lines (users) remotely, using secure HTTP requests. This is especially useful for automation, resellers, third-party apps, or panel integrations.
ā Step 1: Enable API Access
To use the API, first whitelist your server IP in the panel:
- Go to: General Settings ā API Settings
- Add your IP address to the Allowed IPs
- Save settings and generate an API key
The API key can be passed:
- Via
POST
parameter (api_key
) - Or as the 4th segment in the URL
š Creating a New Line
Endpoint:
http://your-domain:8000/api/line/new
Request Method:POST
Example PHP Code:
$panel_url = 'http://your-domain:8000/';
$api_key = 'your_api_key';
$username = 'test_user';
$password = 'test_pass';
$max_connections = 1;
$restreamer = 1;
$subscription_plan = 1;
$expire_date = strtotime("+1 month");
$post_data = array(
'api_key' => $api_key,
'data' => array(
'username' => $username,
'password' => $password,
'max_allowed_connections' => $max_connections,
'restreamer' => $restreamer,
'expire_date' => $expire_date,
'subscription_plan_id' => $subscription_plan
)
);
$options = array('http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query($post_data)
));
$context = stream_context_create($options);
$result = json_decode(file_get_contents($panel_url . "api/line/new", false, $context), true);
ā Successful Response:
{"result":true,"created_id":14838,"username":"d4PSc7uCqF","password":"2ZiSRRZk4b"}
ā Error Example:
{"result":false,"error":"Username exists."}
āļø Editing an Existing Line
Endpoint:
http://your-domain:8000/api/line/update
Required: username
Optional: any field from lines
table (e.g. password, max connections, expiration, restreamer)
$post_data = array(
'api_key' => $api_key,
'username' => 'test_user',
'data' => array(
'password' => 'new_pass',
'max_allowed_connections' => 10,
'restreamer' => 1,
'expire_date' => strtotime("+1 month")
)
);
ā Success:
{"result":true,"modified_id":1234,"username":"test_user","password":"new_pass"}
ā Deleting a Line
Endpoint:
http://your-domain:8000/api/line/delete
Required:
> $api_key,
'username' => 'test_user'
);
š Viewing Line Info
Endpoint:
http://your-domain:8000/api/line/info
phpCopyEdit$post_data = array(
'api_key' => $api_key,
'username' => 'test_user'
);
Sample Output:
{
"result":true,
"info":{
"expire_date":"2024-12-01",
"max_allowed_connections":3
},
"conn_info":{
"current_connections":1
},
"channel_ids":[12, 14, 18]
}
š§ Pro Tips
- Leave
username
orpassword
blank to auto-generate values - You can send arrays for
allowed_ips
,allowed_user_agents
,notes
,server_id
,isp_lock
, etc. - All errors are logged under: LOGS ā Panel Error Log