Search code examples
wowza

How to retrieve the current listeners from a wowza cloud live stream via api?


We are using the wowza cloud to run a weekly live streaming event. Is there a way to get the current listeners as live data from the api?

We found two endpoints, but they appear to be equally dysfunctional:

  1. https://api.cloud.wowza.com/api/v1.4/usage/stream_targets/y7tm2dfl/live leads to
​{
    "meta": {
        "status": 403,
        "code": "ERR-403-RecordUnaccessible",
        "title": "Record Unaccessible Error",
        "message": "The requested resource isn't accessible.",
        "description": ""
    },
    "request_id": "def6744dc2d7a609c61f488560b80019",
    "request_timestamp": "2020-03-27T19:54:14.443Z"
}​
  1. https://api.cloud.wowza.com/api/v1.4/usage/viewer_data/stream_targets/y7tm2dfl leads to
​{
    "meta": {
        "status": 404,
        "code": "ERR-404-RouteNotFound",
        "title": "Route Not Found Error",
        "message": "The requested endpoint couldn't be found.",
        "description": ""
    },
    "request_id": "11dce4349e0b97011820a39032d9664a",
    "request_timestamp": "2020-03-27T19:56:01.637Z"
}​

y7tm2dfl is one of the two stream target ids, we get from calling https://api.cloud.wowza.com/api/v1.4/live_streams/nfpvspdh/stats

Is this the right way? According to this question the data might be only available with an delay of 2 hours...

Anybody knows of something, that can actually count as live data?

Thx a lot!


Solution

  • From Wowza Support:

    The below endpoint is the correct one to use for near realtime view counts:

    curl -H "wsc-api-key: ${WSC_API_KEY}" \
      -H "wsc-access-key: ${WSC_ACCESS_KEY}" \
      -H "Content-Type: application/json" \
      -X "GET" \
      "https://api.cloud.wowza.com/api/v1.4/usage/stream_targets/y7tm2dfl/live"
    

    It appears this stream target "y7tm2dfl" is an Akamai push and will have 2 or more hours timeframe to get results. You'll need to create a new stream target that uses Fastly to take advantage of the near realtime stats. https://www.wowza.com/docs/add-and-manage-stream-targets-in-wowza-streaming-cloud#add-a-wowza-cdn-on-fastly-target-for-hls-playback

    This will retrieve the "Current Unique Viewers", which is defined as "the number of unique viewers for the stream in the last 90 seconds". This is only available with Fastly Stream Targets in api 1.4.