Control Panel — API Documentation

Documentation

API Documentation: sevu.request

Synopsis

This API creates a SEVU ticket. This ticket allows a user to view a protected video. This system allows you to restrict access to a specific video or subset of videos, to a specific IP address, timeframe and usage count.

Example Code (php)

$request = array(
        'command' => 'sevu.request',
        'api_key' => 'ZGQWNWVKOGQZYJAXNTIYMTCXOTAWMWVK',
        'timestamp' => time(),
        'cdn' => 28,
        'app' => 'stef-chorigin',
        'video' => 'mystream',
        'pass' => 'unique_random_string_per_request',
        'ip' => '192.168.0.0/24',
        'uses' => 5,
        'expire' => '2021-08-25 01:16:39',
    );
    
    //Create request signature
    $json_request = json_encode($request);
    $sig = base64_encode(hash_hmac('sha256', $json_request,
        '479e4b01ebfb61bc015cf4b3145f139d97cf43c7340965feb24082da45dd60f3', 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
    
    $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
timestamp [REQUIRED] [int] - The unix timestamp of your request, used to prevent authenticated API requests from being replayed
app [REQUIRED]
  • [string] - The ScaleEngine Application name to restrict viewing to
  • [string] - A pipe separated list of applications, optionally with wildcards.
    Example: myapp-vod|otherapp-*
video [REQUIRED]
  • [string] - The stream name or path of the VOD video the user is restricted to. VOD examples look like like: sestore3/username/path/filename.mp4
  • [string] - One of more stream name or VOD path separated by a pipe, optionally with wildcards. This allows for things like multi-bitrate streams or files, or allowing users access to a group of streams and videos.
    Example: mystream_* will match mystream_720p and mystream_360p.
    Example: file1.mp4|file2.mp4 will only allow the listed files to play
    Example: sestore3/username/set1/*|sestore3/username/set2/* will match any file in those directories
pass [REQUIRED] [string] - A randomly generated password. Should be unique for each request. Recommended length atleast 10 characters.
ip [REQUIRED]
  • [string] - The IP address to allow access from
  • [string] - The CIDR mask of a range of IP addresses to allow access from.
    Example: 192.168.0.0/24
    Example: 0.0.0.0/0 allows any IP address
  • [string] - The literal string 'auto' or 'auto/24'. This will update the ticket the first time it is used to restrict it to the IP address of the user. This will prevent account sharing, while at the same time dealing with edge cases such as users behind corporate firewalls or proxies that may have a different IP address on the website than they will use to access the video stream
uses [REQUIRED] [int] - The number of times the video will be allowed to start. This can be used to restrict how many times a ticket may be used, and helps further protect against account sharing
expire [REQUIRED] [datetime] - The expiration date of the ticket. After this time, access will no longer be allowed, the user will require a new ticket.
Example: 2024-12-22 00:24:11

Example Result (JSON)

    {
    "code": 2002,
    "message": "ScaleEngine Virtual Usher Ticket Granted",
    "status": "success",
    "ticket": {
        "key": "mystream.53ffc996dd39d5.39102367",
        "pass": "g63clVAI5wFPxY9vwVOJvw6L",
        "ip": "0.0.0.0/0",
        "video": "mystream",
        "app": "myapp-sevu",
        "created_date": "2014-08-29 00:30:14",
        "used_date": "0000-00-00 00:00:00",
        "uses": "5",
        "active": "1"
        },
    "handle_time":"0.3795 seconds"
    }
    

Result Fields

code [int] - API Response Code
message [string] - Debugging message
status [string] - "success" or "failure"
ticket
key [string] - The SEVU ticket. This is the string that combined with the password provided when the ticket was created allows a user access to a protected stream. Must be included in the server URL as the "key" parameter
pass [string] - The password provided by you when you requested the ticket. Must be included in the server URL as the "pass" parameter
ip [string] - The IP address provided in the request
video [string] - The video(s) or stream(s) that this ticket is valid for
app [string] - The application(s) that this ticket is valid for
created_date [datetime] - The datetime the ticket was created
used_date [datetime] - The datetime of the first time this ticket was used by a user
uses [int] - How many uses remain for this ticket, this number is decremented each time the ticket is used
active [bool] - 1 if the ticket is still active, 0 if it has been revoked
handle_time [float] - The amount of time spent processing your request