Can I access all live broadcasts with YouTube's LiveStreaming API? - youtube

Meerkat allows access to all its live broadcasts via REST API. Does YouTube's live streaming API allow the same? I can see that they allow CRUD through the API for a particular user. My question is can I access all live broadcasts with the API?

You can use the Search/list endpoint of the regular YouTube v3 API and filter the results to only receive live content. Make sure to pass in the following parameters:
part -> snippet
eventType -> live
type -> video (required when setting eventType to live)
The full get request:
HTTP GET https://www.googleapis.com/youtube/v3/search?part=snippet&eventType=live&type=video&key={YOUR_API_KEY}

Related

Youtube content owner API returns 403 forbidden error

The API Explorer returns 403 forbidden with fetchMine=True https://developers.google.com/youtube/partner/docs/v1/contentOwners/list
Used Google OAuth 2.0 and API key. Is it compulsory to be a a partner to gain access to the data?
directly from the documentation page.
ContentOwners: list
Note: The YouTube Content ID API is intended for use by YouTube content partners and is not accessible to all developers or to all YouTube users. If you do not see the YouTube Content ID API as one of the services listed in the Google API Console, see the YouTube Help Center to learn more about the YouTube Partner Program.
answer
you need to be a YouTube partner to access this method.

Need an Api or webhook for youtube streaming notification

I need to find an Api/webhook, source code for youtube. Specifically, that Api/webhook will send me a notification only when a specific youtuber makes a direct live streaming transmission.
Thanks for your help.
You may refer with this link: Is there a way to get notifications from YouTube API when broadcaster is live. It stated that 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.
Also, you may use the GET https://www.googleapis.com/youtube/v3/liveBroadcasts endpoint which 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.

How to know `on_behalf_of_content_owner` for Youtube Analytics API?

I want to use list_batch_report_definitions method in Youtube Analytics API V2.
http://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/YoutubeAnalyticsV1/YouTubeAnalyticsService#list_batch_report_definitions-instance_method
But I don't know what is on_behalf_of_content_owner and how to get it.
onBehalfOfContentOwner string
The ID of the content owner for whom the API request is being made. If the request does not specify a value for this parameter, the
API server assumes that the request is being made for the user's own
channel.
ID Identifies the YouTube channel or content owner for which you are >retrieving YouTube Analytics data.
Note: Content owner reports are only accessible to YouTube content partners who participate in the YouTube Partner Program.
I suspect once you have been accepted into this partner program you will be given access to the content owner id.

Is it possible to allow many users to make live broadcasts using YouTube API and a single account?

I want to make a web application and I want to use YouTube API to allow my users make live broadcasts.
Is it necessary that my users log with their Google/YouTube accounts to use the live stream or is it possible to make them use this function without bothering them with this detail?
In order to create the Live Event and Live Stream objects required for a livestream on YouTube, the user making those requests must be authenticated.
From the Docs:
Your application must have authorization credentials to be able to use the YouTube Live Streaming API.
Obtaining authorization credentials guide here.
Adding a live event is similar to uploading a video. The user making the upload must be authenticated in order for the video to appear on their channel.

Using YouTube API v3 to tell if a channel has a live stream

The goal of my YouTube API call is, given a channelId, to return whether that channel is currently live streaming. This is the call I'm making currently:
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={CHANNEL_ID}&eventType=live&type=video&key={YOUR_API_KEY}
While this call is functional, there is a significant delay between the channel starting a live stream and this call returning the stream.
Is there a better call to use in the YouTube v3 API that doesn't require oAuth? The functionality of my app is read-only.
Thanks!
Probably late but still someone else would use it, i found the answer on google api docs:
https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/list
(Scroll to bottom, you can use their onsite api to make calls on the fly)
The call you have to make is:
GET https://www.googleapis.com/youtube/v3/liveBroadcasts?part=id%2Csnippet%2Cstatus&mine=true&broadcastStatus=active&key={YOUR_API_KEY}
(atm, they have an issue wth the status field). You can remove the filter and check the returned results for
{ "status": { "lifeCycleStatus": "live"}}
And as per google docs:
Before you start
You need a Google Account to access the Google Developers Console, request an >API key, and register your application.
Register your application with Google so that it can submit API requests.
After registering your application, select the YouTube Data API as one of the >services that your application uses:
Go to the Developers Console and select the project that you just registered.
Open the API Library in the Google Developers Console. If prompted, select a >project or create a new one. In the list of APIs, make sure the status is ON for >the YouTube Data API v3 and, if you are a YouTube Content Partner, the YouTube >Content ID API.
Calling the Data API
The API request must be authorized by the Google Account that owns the >broadcasting YouTube channel.
You can check this link for generating an access(OAuth 2.0) token: https://developers.google.com/identity/protocols/OAuth2?hl=en
I hope this helps.
I was digging for a "cheaper" way to find if a channel is live to save some API quota. I attempted to use Konstantin's workaround by looking at the {channel/channel_id}/live but this appears to not work anymore.
The channel no longer redirects when a person is live. Instead it runs on that page.
If they have a username URL then /c/ works: https://www.youtube.com/c/USER_NAME/live
If they have don't have a username and use the default like UC4R8DWoMoI7CAwX8_LjQHig, then you need to use https://www.youtube.com/channel/USER_NAME/live
The /search call is rather expensive. If you are only allotted the initial 10k quota points, you'd run out of points after only 100 queries. That may not be a bother for some use cases, but it is nevertheless limited.
Instead, you can use Playwright and do the following:
page.goto("https://YouTube.com/channel/{channel id}/live")
Then check for a redirection which will happen when the channel is live:
const redirect = page.url()
If redirect contains a link to a YouTube video, then you know the channel is live. Otherwise it is not live and will yield a link similar to the one that's passed in to the goto() function.

Resources