viewer hours

This deprecated metric returns the number of viewer hours.

Updated 2026-08-03 viewer-hours

viewer hours

Deprecated: This API (insights/2.5) is deprecated and no longer supported. Only version 3.0 (insights/3.0) is supported. Use the Metrics V3 API Guide instead.

Gets the number of viewer hours.

Key:

viewer_hours

Resource URI:

/metrics.json

Method:

GET

Query Parameters

Example Query String:

?metrics=viewer_hours&filter_ids={{filter_ids}}&day={{day}}

Required:

  • /metrics.json?metrics=viewer_hours - Gets the number of viewer hours.
  • filter_ids={{filter_ids}} - The call must specify one or more comma-separated filter IDs. To get filter IDs, call the /filters endpoint.

Optional:

  • Specify one of the following time periods for historical data. No time parameter specifies live data.

    • day={{yyyy-mm-dd}}
    • month={{yyyy-mm}}
    • start_day={{yyyy-mm-dd}}&{{end_day=yyyy-mm-dd}}
    • start_time={{yyyy-mm-dd:hh}}&{{end_time=yyyy-mm-dd:hh}}

    If you specify the current month, the period extends from the first day of the month to today or yesterday.

    For an hourly range, specify both the start and end times including the hour of the beginning and ending day for which to return data.

    Each API call returns up to 30 days of data.

    Data is available for up to 13 months.

    Note: The Experience Insights APIs return data in the time zone for the c3 account.

    • advanced={{boolean}} - Specifies whether the filter is enabled for Pulse MetricLens and Diagnostics dashboards. Default is False.

    • category={{string}} - A string that specifies the filter's category name (group) in Pulse. Allowed options are "CONTENT", "DEVICE", "OTHER", "GEO", "NETWORK". Use this parameter to list all categories created for your filters. If no category is specified, the default value is 'OTHER'.

    • content={{boolean}} - Specifies the if the filter computation applies to the Top Content metrics. The default value is False.

    • created={{date}} - String that specifies the filter creation date and time in ISO format, YYYY, YYYY-MM, or YYYY-MM-DD.

    • creator={{string}} - Specifies the filter's creator name.

    • edited={{date}} - String that indicates filters last edited time and date, in ISO format, YYYY, YYYY-MM, or YYYY-MM-DD.

    • editor={{string}} - Specifies the last person who edited the filter.

    • enabled={{boolean}} - Specifies the filters state. The default value is "true".

    • id={{int}} - Specifies the filter's unique ID number.

    • name={{string}} - Specifies the filter's coma separated alphanumeric name. For example "Automation Testing 2019.06.04.12.54.11".

    • rules={{object}} - Displays the filter's rules or the criteria applied by the filter. The rules display as an array but consider it a string for search purposes. Rules contain up to four fields: "field" (one of the filter dimensions), "op" (operation or/and), "value" (user specified) and "key" (if the rule is custom tag based).

    • sub-category={{sub-group}} - A string that specifies the filter's sub-category name (sub-group) in Pulse, e.g. Country. Use this parameter to list all sub-categories created for your filters. If no category is specified, the default value is 'OTHER'.

Limitations:

5-minute granularity is available with the 'granularity=5min' parameter. Unless this parameter is specified, data is hourly.

Example Request

Copy
curl
  'https://api.conviva.com/insights/2.5/metrics.json?metrics=viewer_hours&filter_ids={{filter_ids}}&day={{day}}' \
  -H 'Cache-Control: no-cache' \
  -u 'client_ID:secret' \

Copy
import base64
import http.client

conn = http.client.HTTPSConnection("api.conviva.com")

encoded = b64encode(b"client_ID:secret").decode("ascii")
headers = {
    'Cache-Control': 'no-cache',
    'Authorization': 'Basic %s' % encoded
    }

api = "/insights/2.5/metrics.json"
query = "?metrics=viewer_hours&filter_ids={filter_ids}}&day={{day}}"
path = api + query
conn.request("GET", path, headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

Copy
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.conviva.com/insights/2.5/metrics.json?metrics=viewer_hours&filter_ids={{filter_ids}}&day={{day}}");
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("Authorization", "Basic " + btoa("client_ID:secret"));

xhr.send(data);

<?php

$request = new HttpRequest();
$request->setUrl('https://api.conviva.com/insights/2.5/metrics.json');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'metrics' => 'viewer_hours',
  'filter_ids' => '{{filter_ids}}',
  'day' => '{{day}}'
));

$request->setHeaders(array(
  'Cache-Control' => 'no-cache'
  'Authorization' => 'Basic'.base64_encode("$client_ID:$secret")
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

Copy
OkHttpClient client = new OkHttpClient.Builder().authenticator(new Authenticator() {
    public Request authenticate(Route route, Response response) throws IOException {
        String credential = Credentials.basic(client_ID, secret);
        return response.request().newBuilder().header("Authorization", credential).build();
    }
}).build();

Request request = new Request.Builder()
  .url("https://api.conviva.com/insights/2.5/metrics.json?metrics=viewer_hours&filter_ids={{filter_ids}}&day={{day}}")
  .get()
  .addHeader("Cache-Control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

Success Response

Response Code:

200

Response Type:

application/json

Response Description:

Live, Historical

Time Series

Returns JSON with the viewer hours.

Example JSON Response

{
    "viewer_hours": {
        "timestamps": [
            1507507200000
        ],
        "meta": {
            "status": 0
        },
        "type": "time_series",
        "filters": {
            "28933": [
                1506374.86
            ]
        }
    }
}

Common Error Responses

Code: 400 Bad request
Content: { reason : "At least one filter_id should be provided." }
Content: { reason : "The credentials you used are not valid. Please check your credentials and try again." }
Content: { reason : "Time range is not valid for metric <metric>. Invalid day format"}

Code: 401 UNAUTHORIZED
Content: { error : "Log in" }

Code: 422 UNPROCESSABLE ENTRY
Content: { error : "Email Invalid" }

Code: 429 Too Many Requests
Content: { error : "Too Many Requests" }

More Information

See Metrics.