Loading Search...
Analytics API Developers Reference

Audience and Overview

This documentation is intended for programmers who are writing client or server applications that interact with the data contained within a Limelight Video Platform account. It provides explanation and examples of basic Application Programming Interface (API) operations using REST, XML, JSON, and YAML.

This documentation assumes that you understand the general principles behind the aforementioned programming languages and concepts.

Table of Contents


1.0 Analytics API Overview

The Limelight Video Platform Analytics API gives developers programmatic access to various viewership metrics within an account. Developers can retrieve data that is normally viewed within the Limelight Video Platform Analytics console, enabling the ability to externally analyze, build custom applications, or integrate with existing systems. Common uses for the Analytics API include aggregating analytics information into custom tables or graphs or displaying analytics information on a web page without granting access to a Limelight Video Platform account.

Specifically, the Analytics API permits the following:
  • Query - Request information pertaining to viewership metrics in an account
Resources and methods pertaining to the above bullet point are described in detail in section 2.0 below.

1.1 REST

All API requests in the Limelight Video Platform Analytics API are REST based and are available through the following base end-point:

http://api.delvenetworks.com/rest/

1.2 Authentication

In order to ensure the security of your information we require some requests to be signed. Those methods indicated below as requiring authentication must have a signature. See section 5.0 below for how to sign requests.

1.3 Errors

Standard errors are returned with 4xx codes and a descriptive message. Internal server errors are returned with a status code of 500.

1.4 Server-side Caching

In order to ensure a fast, reliable, and responsive site, we recommend that all interaction with the Analytics API be done on the server. For example, don't try to call the API on every page load of your hugely popular website. Instead, call the API only to periodically update a local cache and save the response, displaying your cached version on your site. Caching is essential to ensuring the reliability of your web application, ensuring robustness and preventing overall network load. For information on a suggested technique to implement caching, see Appendix B below.


2.0 API Requests - Overview Report Metrics

Requests for analytics about the media, channel, referrers, and usage content in your account can be accomplished using our suite of GET requests. All results are returned in JSON format by default. You can specify an alternative response format (such as XML or YAML) by applying a 'dot-extension' on the end of the resource path.

The following methods are available for requesting 'Overview' metrics for media, channels, and referrers:

2.1 Media Overview Report - Most Viewed Videos

As seen in the Limelight Video Platform console:


Data for the above report can be retrieved programmatically via the following method:

GET Method for Most Viewed Videos

Get 10 most viewed videos

Get a list of the 10 most viewed videos for a timeframe

URL

http://api.delvenetworks.com/rest/organizations/<org id>/analytics/overview/media.{xml,json,yaml}

Formats

XML, JSON, YAML

HTTP Method

GET

Requires Authentication

Optional Parameters

media_id = <comma-separated list of media IDs indicating relevant media>
start = <Unix time, represented as the number of seconds since the Unix epoch>
end = <Unix time, represented as the number of seconds since the Unix epoch>

Response

An overview of the 10 most popular media between the specified dates

Errors

Invalid start/end dates

Example Usage

Example code for this method can be found in section 6.1.1

Data returned by a call to this method:

Property Name Description
media_id A unique identifier for the media
media_type Either 'audio' or 'video'
media_title The title of the media
times_plays Number of times the media has been played
total_time_viewed Total amount of time the media has been viewed (in milliseconds)
times_embedded Number of times the media embed code has been copied
times_emailed Number of times the media has been shared via email
start_date Start date of report
end_date End date of report

2.2 Channel Overview Report - Most Viewed Channels

As seen in the Limelight Video Platform console:


Data for the above report can be retrieved programmatically via the following method:

GET Method for Most Viewed Channels

Get most viewed channels

Get a list of the most viewed channels for a timeframe

URL

http://api.delvenetworks.com/rest/organizations/<org id>/analytics/overview/channels.{xml,json,yaml}

Formats

XML, JSON, YAML

HTTP Method

GET

Requires Authentication

Optional Parameters

channel_id = <comma-separated list of channel IDs indicating relevant channels>
start = <Unix time, represented as the number of seconds since the Unix epoch>
end = <Unix time, represented as the number of seconds since the Unix epoch>

Response

An overview of the most popular channels between the specified dates

Errors

Invalid start/end dates

Data returned by a call to this method:

Property Name Description
channel_id A unique identifier for the channel
channel_title The title of the channel
num_sessions Number of unique sessions in which the channel has been played at least once
num_plays Number of times the channel has been played (i.e. user clicks on play or channel automatically plays)
start_date Start date of report
end_date End date of report

2.3 Referrers Overview Report - Top Traffic Sources

As seen in the Limelight Video Platform console:


Data for the above report can be retrieved programmatically via the following method:

GET Method for Top Traffic Sources

Get the top 10 traffic sources

Get a list of the top 10 traffic sources (domains) for a timeframe

URL

http://api.delvenetworks.com/rest/organizations/<org id>/analytics/overview/referrers.{xml,json,yaml}

Formats

XML, JSON, YAML

HTTP Method

GET

Requires Authentication

Optional Parameters

start = <Unix time, represented as the number of seconds since the Unix epoch>
end = <Unix time, represented as the number of seconds since the Unix epoch>

Response

A list of domains representing the top 10 traffic sources for the given timeframe

Errors

Invalid start/end dates

Data returned by a call to this method:

Property Name Description
num_referrer_views Number of times the media has been played from the referring website
referrer_host Domain of referring website where embedded content has been played
start_date Start date of report
end_date End date of report

3.0 API Requests - Performance and Engagement Metrics

The following methods are available for requesting performance and engagement metrics for media and channels:

3.1 Media Report (Audio or Video)

As seen in the Limelight Video Platform console:


Data for the above report can be retrieved programmatically via the following method:

GET Method for Media Details

Get full analytics details for media

Get comprehensive media performance metrics

URL

http://api.delvenetworks.com/rest/organizations/<org id>/analytics/report/media.{xml,json,csv}

Formats

XML, JSON, CSV

HTTP Method

GET

Requires Authentication

Optional Parameters

media_id = <comma-separated list of media IDs indicating relevant media>
period = <'today', 'yesterday', 'this_week_so_far', 'last_week', 'this_month_so_far', 'last_month', 'all_time', 'custom'>

Note: Values for 'start' and 'end' are only used if a period of 'custom' is specified.

start = <Unix time, represented as the number of seconds since the Unix epoch>
end = <Unix time, represented as the number of seconds since the Unix epoch>

Response

List containing the detailed media analytics over the given report period

Errors

Invalid period

Data returned by a call to this method:

Property Name Description
media_id A unique identifier for the media
media_type Either 'audio' or 'video'
media_title The title of the media
ref_id The reference ID of the media. This is typically an internally used media reference ID, possibly from an existing CMS
times_plays Number of times the media has been played
total_time_viewed Total amount of time the media has been viewed (in milliseconds)
times_embedded Number of times the media embed code has been copied
times_emailed Number of times the media has been shared via email
start_date Start date of report
end_date End date of report

3.2 Channel Report

As seen in the Limelight Video Platform console:


Data for the above report can be retrieved programmatically via the following method:

GET Method for Channel Details

Get full analytics details for channels

Get comprehensive channel performance metrics

URL

http://api.delvenetworks.com/rest/organizations/<org id>/analytics/report/channels.{xml,json,csv}

Formats

XML, JSON, CSV

HTTP Method

GET

Requires Authentication

Optional Parameters

channel_id = <comma-separated list of channel IDs indicating relevant channels>
period = <'today', 'yesterday', 'this_week_so_far', 'last_week', 'this_month_so_far', 'last_month', 'all_time', 'custom'>

Note: Values for 'start' and 'end' are only used if a period of 'custom' is specified.

start = <Unix time, represented as the number of seconds since the Unix epoch>
end = <Unix time, represented as the number of seconds since the Unix epoch>

Response

List containing the detailed channel analytics over the given report period

Errors

Invalid period

Data returned by a call to this method:

Property Name Description
channel_id A unique identifier for the channel
channel_title The title of the channel
num_sessions Number of unique sessions in which the channel has been played at least once
num_plays Number of times the channel has been played (i.e. user clicks on play or channel automatically plays)
start_date Start date of report
end_date End date of report

3.3 Engagement Report

As seen in the Limelight Video Platform console:


Data for the above report can be retrieved programmatically via the following method:

GET Method for Engagement Data

Get engagement metrics for media

Get a comprehensive listing of media engagement metrics

URL

http://api.delvenetworks.com/rest/organizations/<org id>/analytics/report/engagement.{xml,json,csv}

Formats

XML, JSON, CSV

HTTP Method

GET

Requires Authentication

Optional Parameters

media_id = <comma-separated list of media IDs indicating relevant media>
period = <'today', 'yesterday', 'this_week_so_far', 'last_week', 'this_month_so_far', 'last_month', 'all_time', 'custom'>

Note: Values for 'start' and 'end' are only used if a period of 'custom' is specified.

start = <Unix time, represented as the number of seconds since the Unix epoch>
end = <Unix time, represented as the number of seconds since the Unix epoch>

Response

List containing the detailed engagement analytics over the given report period

Errors

Invalid period

Data returned by a call to this method:

Property Name Description
media_id A unique identifier for the media
media_title The title of the media
ref_id The reference ID of the media. This is typically an internally used media reference ID, possibly from an existing CMS
plays Number of times the media has been played
avg_time_played_in_seconds The total number of played seconds divided by the total number of plays.
XX_percent_watched Represents the number of plays as a relative amount of the total video duration. It is the percentage of the video watched by a viewer (ignoring portions of the video that are 're-watched' or scrubbed back to). The following are reported: 25%, 50%, 75%, 100%
segment_XX.X This is the number of viewers that watched a particular segment within a video. A video is broken into 40 segments where each segment represents 2.5% of the total video duration. The 40 segments are used to plot the dropoff graph.

4.0 API Requests - Usage Metrics

The following method is available for requesting 'Usage' information (bandwidth & storage) for an account:

4.1 Usage Report (Bandwidth and Storage)

As seen in the Limelight Video Platform console:


Data for the above report can be retrieved programmatically via the following method:

GET Method for Usage Information

Get usage information for an account

Get bandwidth and storage usage data

URL

http://api.delvenetworks.com/rest/organizations/<org id>/analytics/report/usage.{xml,json,yaml}

Formats

XML, JSON, YAML

HTTP Method

GET

Requires Authentication

Optional Parameters

start = <Unix time, represented as the number of seconds since the Unix epoch>
end = <Unix time, represented as the number of seconds since the Unix epoch>
span = <'daily', 'monthly', 'yearly'>

Response

Storage and bandwidth statistics for the specified dates, aggregated over the span

Errors

Invalid span
Invalid start/end dates

Example Usage

Example code for this method can be found in section 6.1.2

Data returned by a call to this method:

Property Name Description
time Unix time, represented as the number of seconds since the Unix epoch at which the report starts
storage_in_megabytes Storage used (in megabytes)
bandwidth_in_megabytes Bandwidth used (in megabytes)
interval Span of time for which the report contains data: daily, monthly, or yearly

5.0 Authentication - Signing Requests

In order to ensure the security of your information we require some requests to be authenticated. All methods indicated above as requiring authentication must have a signature. A signature is generated by doing an HMAC 264 hash on the request URL and its parameters. In order to do this you will need to obtain your unique access_key and secret. The access_key is passed as a normal parameter to the URL. The secret is used to generate a signature by performing a hash. Both the access_key and secret can be found in your Limelight Video Platform account, under the 'Developer Tools' tab in 'Settings'. Lastly, you will need to determine a value for the expires parameter. This value, represented in Unix Time, indicates when the URL should no longer return results. A handy Unix Time converter can be found here: http://www.epochconverter.com

To illustrate the steps involved in generating a signature, we provide an example below. In this example, we authenticate the URL used to 'Get usage information for an account':

We will use the following variables for this example:
Org ID:bfb3caa8e6204fea9a23ce855768fc93
Access Key:esU4jGTelX8UAsfaiWUcjWsn1mY=
Secret:+IEbSWOctQhnMi7DGop9KdPysqw=
Expires:1298347550
Start:1262304000
Span:monthly
  1. Start with the base URL for your request. The base URL for 'Get usage information for an account' looks like this:
    http://api.delvenetworks.com/rest/organizations/bfb3caa8e6204fea9a23ce855768fc93/analytics/report/usage.xml
  2. Drop the 'http://' prefix and append the http verb ('get', 'post', 'put', 'delete') to the front of the base URL and surround the host of the URL and the path of the URL with the '|' symbol. Make sure everything is lower case. Our URL string now looks like this (notice there are three places where the '|' symbol has been inserted):
    get|api.delvenetworks.com|/rest/organizations/bfb3caa8e6204fea9a23ce855768fc93/analytics/report/usage.xml|
  3. Next, sort the list of parameters alphabetically and append them as <key>=<value> pairs to the end of the URL string. Separate all parameters with the '&' symbol. Our URL string now looks like this (the parameters are bolded):
    get|api.delvenetworks.com|/rest/organizations/bfb3caa8e6204fea9a23ce855768fc93/analytics/report/usage.xml|access_key=esU4jGTelX8UAsfaiWUcjWsn1mY=&expires=1298347550&span=monthly&start=1262304000
  4. Now, using your secret, generate a sha256 HMAC hash in base 64 format on the URL string. The result of this hash will be your signature. In this example, our signature looks like this:
    oNo+t/o7DNBPUTKyRCiUiz9/t4d51a9/RgDHGLqB+6M=
  5. Lastly, create the final executable URL by beginning with the base URL. Append all the parameters in alphabetic order, starting with '?' and separated by '&'. URL encode all key and values on your parameters. Finally, URL encode the signature you generated above and append it at the end as signature=<signature>. The final executable URL looks like this:
    http://api.delvenetworks.com/rest/organizations/bfb3caa8e6204fea9a23ce855768fc93/analytics/report/usage.xml?access_key=esU4jGTelX8UAsfaiWUcjWsn1mY%3D&expires=1298347550&span=monthly&start=1262304000&signature=oNo%2Bt%2Fo7DNBPUTKyRCiUiz9%2Ft4d51a9%2FRgDHGLqB%2B6M%3D

5.1 Code to Perform Authentication

Limelight offers the following code to aid in authenticating requests. Simply drop this into your project and call the authentication function with the right parameters. The result will be an authenticated request:
PHP LvpAuthUtil.php
Ruby LvpAuthUtil.rb
Java LvpAuthUtil.java
C# LvpAuthUtil.cs
VB LvpAuthUtil.vb
Python LvpAuthUtil.py

6.0 Example Code

The following are examples of executing some of the methods in the above sections.

6.1 PHP

All PHP code examples make use of the following code in order to authenticate requests: LvpAuthUtil.php

6.1.1 (Example 1) Get most viewed videos - Media Overview Report

(Download the complete code for this example here: api_analytics_example.txt)

A list of of the most viewed videos can be obtained with a GET method to the following URL:
http://api.delvenetworks.com/rest/organizations/<org id>/analytics/overview/media

However, this method requires authentication. The URL must first be signed before execution. In this example, a call to the following function returns the signed URL. The parameters to the function are the URL to be authenticated, your authentication access key, and your authentication secret:
  $access_key = "<INSERT_YOUR_ACCESS_KEY>";
  $secret = "<INSERT_YOUR_SECRET>";
  $org_id = "<INSERT_YOUR_ORG_ID>";
  $url = 
   "http://api.delvenetworks.com/rest/organizations/$org_id/analytics
          /overview/media";

  $signed_request = DelveAuthUtil::authenticate_request("GET", $request, $access_key, $secret);

The above function returns an authenticated URL. This URL can then be executed and the response parsed. In this example, the response is parsed to display the number of views for the first returned video.
  $response = file_get_contents($signed_request);
  
  $media_overview = json_decode($response);
  $first_media = $media_overview[0];
  echo("

'" . $first_media -> media_title . "' has been watched " . $first_media -> times_views . " times.

");

6.1.2 (Example 2) Get Usage Information for an Account - Usage Report

(Download the complete code for this example here: api_get_usage_info.txt)

Usage information (bandwidth and storage usage) for an account can be obtained through a GET method to the following URL:
http://api.delvenetworks.com/rest/organizations/<org id>/analytics/report/usage

However, this method requires authentication. The URL must first be signed before execution. The following code illustrates the authentication:
<?php 
  $access_key = "<INSERT_YOUR_ACCESS_KEY>";
  $secret = "<INSERT_YOUR_SECRET>";
  $org_id = "<INSERT_YOUR_ORG_ID>";

  # these parameters are optional but in this example we illustrate their usage
  $span = "monthly";
  $start = <ENTER A DESIRED UNIX START TIME>;

  $get_usage_info_url = 'http://api.delvenetworks.com/rest/organizations/' .$org_id .'/analytics/report/usage.xml';

  # obtain a signature for getting the usage info
  $signed_get_usage_info_url = DelveAuthUtil::authenticate_request("GET", $get_usage_info_url, $access_key, $secret, array("span" => $span, "start" => $start));
?>  

The authenticated URL, returned by the above call to authenticate_request can then be used to get the usage information. The following example executes the signed request and displays the XML response:
  $response = file_get_contents($signed_get_usage_info_url);

  # display the result of the above GET
  echo $response;


Appendix A

Example GET Request Response

API GET request for 'Media Details Report' (prior to authentication):
http://api.delvenetworks.com/rest/organizations/6d4242bd0cf94083a0195bfc2083e46e/analytics/report/media.xml

Returned Results:
<records type="array">
    <record>
         <media-id>db0713f8f58a4828b02601758a74be17</media-id>
         <media-type>Video</media-type>
         <media-title>Dinosaur_Jr.: Over It - Music Video</media-title>
         <times-plays type="integer">100</times-plays>
         <total-time-viewed type="integer">7714048</total-time-viewed>
         <times-embedded type="integer">1</times-embedded>
         <times-emailed type="integer">0</times-emailed>
         <start-date type="integer">0</start-date>
         <end-date type="integer">1253516400000</end-date>
   </record>
   <record>
         <media-id>7cd25946e64e48d1a75dfa58a5ccc533</media-id>
         <media-type>Video</media-type>
         <media-title>Draft Profile: Donald Washington</media-title>
         <times-plays type="integer">9</times-plays>
         <total-time-viewed type="integer">316738</total-time-viewed>
         <times-embedded type="integer">0</times-embedded>
         <times-emailed type="integer">0</times-emailed>
         <start-date type="integer">0</start-date>
         <end-date type="integer">1253516400000</end-date>
   </record>
</records>

Appendix B

File Swap Caching

Information courtesy of Yahoo, http://developer.yahoo.com/php/howto-cacheRestPhp.html

File swap caching is a simple flat-file caching technique. In essence, it does nothing more than store your Web service requests in local files. When a file becomes too old (when the cache becomes "stale"), the file is deleted and replaced by a fresh Web service request. To make a Web services request using the cache, you call the caching function instead of making a direct request.

$response = request_cache($request, $cache_fullpath,$cache_timeout);

The three parameters are the actual request URL, the path to the cached version of the request, and the number of seconds before the cache becomes stale:

$request =
'http://api.delvenetworks.com/rest/organizations/7fd6def47cde
4d5694f9b16bfa04c521/media.xml';
$cache_fullpath = '/mydir/ImageMad1';
$cache_timeout = 7200;

Here, we arbitrarily chose the name ImageMad1 as the cache file name corresponding to this particular Web services request. Typically, however, you would have a unique file name corresponding to each variation of Web services request. So, you would need to come up with a mapping function to map requests into file names if you want to use the caching with different variations of Web services requests.

The function request_cache does all the real work. First, it checks to see if the request has already been cached or if it has become stale.

function request_cache($url, $dest_file, $timeout) {
   if (!file_exists($dest_file) || filemtime($dest_file) < (time()-$timeout)) {

If the request has not been cached or it is stale, then we make the request and cache it:

$data = file_get_contents($url);
$tmpf = tempnam('/tmp','YWS');
$fp = fopen($tmpf,"w");
fwrite($fp, $data);
fclose($fp);
rename($tmpf, $dest_file);

Otherwise, we return the contents of the cached request:

} else {
   return file_get_contents($dest_file);

A potential problem arises if more than one user of your Web application accesses a cached file just as it is being deleted and refreshed. The statement rename($tmpf, $dest_file) appears to destroy the currently cached version of the file (if any). However, the way the Unix filesystem is implemented guarantees that any process currently reading the previous cache file will continue to read it until it closes the file. So, no process will be cut off or otherwise damaged by the rename.

See the following code sample:

http://developer.yahoo.com/php/samples/cache/cacheSWAP.txt