API

API (Application Programming Interface) is a set of methods that allow to access the features or data of Astra from external applications.

Stream Management

set-stream

This method create, remove, or modify streams. Request:

{
    "cmd": "set-stream",
    "id": "...",
    "stream": {
        "enable": true,
        "type": "spts",
        "id": "...",
        "name": "...",
        "input: [ ... ],
        "output: [ ... ]
    }
}

To remove stream send similar request:

{
    "cmd": "set-stream",
    "id": "...",
    "stream": {
        "remove": true
    }
}

get-stream

Get stream options. Request:

{
    "cmd": "get-stream",
    "id": "..."
}

Response:

{
    "get-stream": "ok",
    "stream": { ... }
}

stream - contains all stream options

toggle-stream

Turn off/on stream. Request:

{
    "cmd": "toggle-stream",
    "id": "..."
}

restart-stream

Restart stream. Request:

{
    "cmd": "restart-stream",
    "id": "..."
}

set-stream-input

Choose active input. Works only for streams with next backup types: passive, disable. Request:

{
    "cmd": "set-stream-input",
    "id": "...",
    "input": "..."
}

input – input number. If option not defined will be started next input after the active —

DVB Management

set-adapter

This method create, remove, or modify adapters. Request:

{
    "cmd": "set-adapter",
    "id": "...",
    "adapter": {
        "enable": true,
        "type": "...",
        "id": "...",
        "name": "...",
        "adapter": 0,
        "device": 0,
        ...
    }
}

To remove adapter and all related streams send similar request:

{
    "cmd": "set-adapter",
    "id": "...",
    "adapter": {
        "remove": true
    }
}

Attention! This method removes all related streams

get-adapter

Get adapter options. Request:

{
    "cmd": "get-adapter",
    "id": "..."
}

Response:

{
    "get-adapter": "ok",
    "adapter": { ... }
}

adapter – contains all stream options

restart-adapter

Restart adapter and all related streams. Request:

{
    "cmd": "restart-adapter",
    "id": "..."
}

Users Management

set-user

This method create, remove, or modify users. Request:

{
    "cmd": "set-user",
    "id": "...",
    "user": {
        "enable": true,
        "type": 0,
        "password": "...",
        ...
    }
}

To remove user send similar request:

{
    "cmd": "set-user",
    "id": "...",
    "user": {
        "remove": true
    }
}

toggle-user

Turn off/on user. Request:

{
    "cmd": "toggle-user",
    "id": "..."
}

Sessions

The method returns a list of current sessions. Answer format:

{
     "cmd": "sessions"
}

The format of the session information: SESSION-INFO:

{
    "client_id": N,
    "channel_id": "...",
    "channel_name": "...",
    "addr": "...",
    "uptime": N
}

To end the session, you must use the close-session method:

{
    "cmd": "close-session",
    "id": N
}

Other

restart astra

Request:

{
    "cmd": "restart"
}

loading configuration

Request:

{
    "cmd": "load"
}

The answer is the contents of the configuration file.

get user config

{
    "cmd": "get-user", "id": "login"
}

get stream status

{
    "cmd": "check-stream", "id": "a001", "status": true
}

Response - content monitoring data.

{
    "status": {
        "onair": "...",
        "active_input": "...",
        "input": [
            {
                "scrambled": "...",
                "cc_error": "...",
                "bitrate": "...",
                "pes_error": "..."
            }
        ]
    },
    "check-stream": "ok"
}

If you pass the request as:

{
    "cmd": "check-stream", "id": "a001"
}

the answer will only
"check-stream": "ok" or "check-stream": "false" - the status of the stream without additional data.

set serial number

{
    "cmd": "set-license", "license": "xxx"
}

Use API

curl

curl -X POST \
    -d '{"cmd": "api-method"}' \
    http://admin:password@127.0.0.1:8000/control/

127.0.0.1:8000 is a server address and Astra port admin:password is an admin login and password

php

$req = json_encode(array(
    'cmd' => 'api-method',
));
$ch = curl_init("http://127.0.0.1:8000/control/");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "admin:password");
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);

127.0.0.1:8000 is a server address and Astra port admin:password is an admin login and password $res is a response data