Search code examples
c#youtube-apiyoutube-livestreaming-api

Getting livestreams from YouTube channel


I am trying to keep track of the livestream viewers of a specific channel. This is no problem when I have got the stream ID and use it manually.

However I want my program to be able to track upcoming livestream automatically. So I want to get the livestream ID from the channel for the next upcoming livestream. I have been looking through the documentation from the API, but I couldn't find anything.

What API call do I need to make?


Solution

  • You cannot get the liveBroadcast or liveStream object that does not belong to the user or channel you are authenticated as. The list endpoint for each object requires you to authenticate as your own channel/user to retrieve your own live events only.

    If you want to retrieve information on another channel's current live broadcasts, you have to use the standard Search/list endpoint:

    part -> snippet

    channelId -> [channelId of the channel/user with the live event]

    eventType -> live

    type -> video (required when setting eventType to live)

    HTTP GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={channelId}&eventType=live&type=video&key={YOUR_API_KEY}