Wowza Community

How to Fetch Viewer Data with Streaming Cloud REST API

Get viewer data with the Wowza Streaming Cloud REST API


The Wowza Streaming Cloud manager does provide a dashboard with near-real time viewer data, but many times a video producer needs a way to capture that data and export it. An example might be a a customer who is paying to advertise during your stream and they require near-real time data during the event as well as complete viewing statistics when the stream has ended. You can easily obtain this data using the Streaming Cloud REST API and potentially automate the process as well.

The REST API response provides detailed information for a single stream target, including the stream target ID, type of target, unique viewers, viewing time, total bytes of usage for the target, and bytes of usage per billing zone.

Wowza Streaming Cloud uses Fastly as default. Fastly stream targets return near real-time viewer data, while Wowza CDN on Akamai stream targets begin to update approximately 2 hours after the transcoder starts and then update approximately hourly.

For complete step-by-step instructions, click HERE.

Fetch live viewer data for a single stream target:

Example Request

curl -X GET \
 -H "wsc-api-key: ${WSC_API_KEY}" \ -H "wsc-access-key: ${WSC_ACCESS_KEY}" \ "${WSC_HOST}/api/${WSC_VERSION}/usage/stream_targets/[ *stream_target_id* ]/live"

To view usage details for ALL stream targets in the account

Example Request:

curl -X GET \
-H "wsc-api-key: ${WSC_API_KEY}" \
-H "wsc-access-key: ${WSC_ACCESS_KEY}" \
"${WSC_HOST}/api/${WSC_VERSION}/usage/stream_targets/[stream_target_id]?from=2019-08-04 15:00:00&to=2019-9-04 15:00:00"

Example Response:

{
    "stream_target": {
        "id": "nlyjx123",
        "type": "fastly",
        "unique_viewers": 35,
        "viewing_time": 181040,
        "bytes": 37073299545,
        "zones": [
            {
                "name": "global",
                "type": "fastly",
                "bytes": 37073299545
            }
        ],
        "limits": {
            "from":"2019-08-04T15:00:00.000Z",
            "to": "2019-09-04T15:00:00.000Z"
        }
    }
}


Get Usage Data for Stream Targets

It’s also possible to capture data on the transcoder usage as well. Usage data includes stream processing time for transcoders, usage for stream targets and VOD streams, egress for transcoders, and peak storage.

To view usage details for all stream targets in the account, call the resource

https://api.cloud.wowza.com/api/[ *version* ]/usage/stream_targets


For a complete list of transcoder data requests, please see the following article for code samples.

(https://www.wowza.com/docs/how-to-view-usage-data-by-using-the-wowza-streaming-cloud-rest-api)

1 Like