Search code examples
jsonvideoyoutubeyoutube-apilive-streaming

How to get current number of viewers for specific live video with YouTube API?


How to get current number of viewers for live video with YouTube API?

I can see number of current viewers using request for feed of videos like this: https://gdata.youtube.com/feeds/api/charts/live/events/live_now?v=2&alt=json&inline=true&max-results=20&start-index=1

It returns me random videos, but I need to get current viewers for specific video. So when I using request for video ( like this https://gdata.youtube.com/feeds/api/videos/fWuS8hM_5D8?v=2&alt=json ) there is no currentViewers field, onlie viewCount.

Is there any solution of this issue?


Solution

  • This is now possible with V3 of the YouTube API ... you request the videos object, passing in the videoID that represents the live stream, and ask for the "liveStreamingDetails" part. One of the parameters returned will be "concurrentViewers" -- for more info:

    https://developers.google.com/youtube/v3/docs/videos#liveStreamingDetails.concurrentViewers