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

    Sessions

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

    {
         "cmd": "sessions"
    }

    The format of the session information: SESSION-INFO:

    {
        "sessions": [
            {
                "client_id": N,
                "channel_id": "...",
                "channel_name": "...",
                "addr": "...",
                "uptime": N
            }
        ]
    }
    • client_id — unique number of the session
    • channel_id — stream ID
    • channel_name — stream name
    • addr — The IP address of the client. To get the IP address from HTTP header X-Real-IP or X-Forwarded-For, while proxying requests, you must use the auth_request.
    • uptime — time, in seconds, since the beginning of the session

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

    {
        "cmd": "close-session",
        "id": N
    }
    • id — session number

    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"
    }

    set serial number

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

    Set image in stream tile:

    {
       "cmd":"set-stream-image",
       "id":"a001",
       "url":"http://..."
    }

    Use API

    curl

    curl -X POST \
        --user 'admin:password' \
        -d '{"cmd": "api-method"}' \
        http://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