Control Panel — API Documentation

Documentation

log.origin

The Origin Log API retrieves the most recent events that have occured on an Application. The log types are publish, unpublish, push, or unpush. Publish logs include whether the attempt was authenticated, the username if one was provided, and the ip address of the encoder. Metadata may be included for events that were logged, such as encoder data for a publish, push settings, or an error message if one occurred. To retrieve log data, the application and stream names are required. By default the latest 25 logs will be returned, but this can be changed by setting a limit and offset.

Example Code (PHP)

    $request = array(
        'command' => 'log.origin',
        'api_key' => 'APX4GKLM0RKQLSP2FBO1ROPKSSW47DZE',
        'timestamp' => time(),
        'cdn' => 158,
        'app' => 'demo-origin',
        'stream' => 'my_stream',
        'limit' => 25, //optional
        'offset' => 0, //optional
    );
    
        //Create request signature
    $json_request = json_encode($request);
    $sig = base64_encode(hash_hmac('sha256', $json_request,
        '8fc8c48da81e6a2a06a9556379bf798af508dc0792497c678b4c3532ba8b637f', true));
    $request['signature'] = $sig;
    $json_request = json_encode($request);
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://api.scaleengine.net/stable/'); // Set the URL
    curl_setopt($ch, CURLOPT_POST, true); // Perform a POST
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // If not set, curl prints output to the browser
    curl_setopt($ch, CURLOPT_HEADER, false); // If set, curl returns headers as part of the data stream
    curl_setopt($ch, CURLOPT_POSTFIELDS, array('json' => $json_request)); //'Json' string or 'PHP' serialized return
    
    //If your PHP host does not have a proper SSL certificate bundle, you will need to turn off SSL Certificate Verification
    //This is dangerous, and should only be done temporarily until a proper certificate bundle can be installed
    //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Turns off verification of the SSL certificate.
    //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Turns off verification of the SSL certificate.
    
    $response = curl_exec($ch); //Execute the API Call
    if (!$response) {
        die('Failed to connect to ScaleEngine API');
    }
    
    //Decode the response as an associative array 
    $arrResponse = json_decode($response, true); 
    if ($arrResponse) {
        //Operation completed successfully
        //TODO Add work here
        print_r($arrResponse);
    } else {
        //Operation failed
        echo 'An error occured processing your request:';
        print_r($response);
    }
    	

Request Fields

command [REQUIRED] [string] - API command to execute
cdn [REQUIRED] [int] - The ScaleEngine CDN ID of your account
api_key [REQUIRED] [string] - The API key provided as part of your account
app [REQUIRED] [string] - The ScaleEngine Application name
stream [REQUIRED] [string] - Stream name or VOD file path
limit [OPTIONAL] [int] - Limits the number of results to be returned.
offset [OPTIONAL] [int] - Number of results to be skipped when searching.

Example Result (JSON)

    {
    "message": "Origin Logs Found",
    "status": "success",
    "handle_time":"0.3795 seconds",
    "logs" : [
        {
            "id" : 1000,
            "app" : "demo-origin",
            "stream" : "my_stream",
            "username" : "",
            "session_id" : 123456789,
            "entry_name" : null,
            "ip_address" : "123.123.123.123",
            "server" : "ser1",
            "log_type" : "publish",
            "logdate" : "2024-04-26 04:40:25",
            "is_auth" : 1,
            "metadata" : { // OBS Example
                "codec":{},
                "metadata":{
                    "duration":"0.0",
                    "fileSize":"0.0",
                    "width":"1024.0",
                    "height":"576.0",
                    "videocodecid":"avc1",
                    "videodatarate":"2800.0",
                    "framerate":"30.0",
                    "audiocodecid":"mp4a",
                    "audiodatarate":"160.0",
                    "audiosamplerate":"44100.0",
                    "audiosamplesize":"16.0",
                    "audiochannels":"2.0",
                    "stereo":"true",
                    "2.1":"false",
                    "3.1":"false",
                    "4.0":"false",
                    "4.1":"false",
                    "5.1":"false",
                    "7.1":"false",
                    "encoder":"obs-output module (libobs version 21.1.0)"
                }
            },
        },
    ],
    "log_count" : 26
    }
	

Result Fields

message [string] - Debugging message
status [string] - "success" or "failure"
handle_time [float] - The amount of time spent processing your request
logs [Array] -
id [int] - Unique Log ID
app [string] - The ScaleEngine Application name
stream [string] - Stream name or VOD file path
username [String] - Username used to authenticate
session_id [String] - Unique Session ID for the stream
entry_name [String] - PushPublish entry name
ip_address [String] - IP Address
server [String] - Unique ID of the server
log_type [String] - Type of log that occured; publish, unpublish, push, or unpush
logdate [String] - Formatted datetime string (Year-Month-Date Hour:Minute:Second)
is_auth [int] - 1: Authenticated, 0: Failed
metadata [Array] - Metadata for the event (see examples section)
log_count [int] - The number of total logs