I'm creating a app that has a database of users who stream there computer game play from YouTube, is there a way to get a notification from YouTube API that will tell me when the gamer is live so I can randomly broadcast each live video for 2 minutes each?
3 Answers
I think it requires a websocket connection with your api endpoint by using ws:// protocole at some point. Websocket listen to a server, and enable your browser to handle it's changes like events. So it's exacly what u need for notifications.
In RoR 5 you can do it using ActionCable.
I've used Rails 5's ActionCable to handle notifications. But sinds I've only used it to listening to changes inside the server of my own Rails app's and not an API endpoint so I won't be able to give you a step by step guide.
You should checkout how to make an action cable connection with an API end point.
Here is a documentaion that might help u out:
The way you looking for is YouTube Live Streaming API.
the documentation of the API can be read from this link
It appears the GET https://www.googleapis.com/youtube/v3/liveBroadcasts
endpoint is what you want.
Returns a list of YouTube broadcasts that match the API request parameters.
However, getting a notification will require some work. It will probably require polling the endpoint for changes to determine if a new broadcast has been started. I'm not aware of a PUSH API from YouTube to send a request to an endpoint of your choice to create a notification.
More info in the Youtube docs.
-
-
It's mentioned here, but doesn't say anything about live broadcasts. Oct 4, 2017 at 7:11