Data is strange when calling youtube/v3/playlistItems API - youtube

Hi https://www.googleapis.com/youtube/v3/playlistItems
I have something to check about the API response data.
[(Completed) Live Streaming] is exposed when you search
with param data playlist ID 'UUpqmToOxz7DlLVRg3MCTalw'.
This data is data that ended in 2016.
It is also not exposed on the YouTube channel of the account.
Under what conditions will that data be exposed?
I don't want to be exposed.
Please let me know if you need additional API information.
What I've tried is to check the return data when calling the "https://www.googleapis.com/youtube/v3/playlistItems" API.
The API exposes data that is not present in the YouTube channel.

Related

Check if youtube channel is livestreaming

I'm trying to get the YT Data API to work and it kinda does work, but I've came across a few inconsistencies where I'm not sure if they are there for a reason.
First: I'm trying to build a discord bot which can announce streams from youtube. Therefore it needs to be able to retrieve channel ids by usernames and live stream information by the retrieved channel id. I want to use the channels endpoint and the search.list endpoint, such that it can do these things automatically (even though it's very expensive).
I'm using this request from the search.list endpoint https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=[channelID]=video&eventType=live&key=[myKey] to check if it actually works. So I picked two completely random channels which were streaming at the time, took the channel id and sent the request. However I only got a response for one of the two channels. The empty response didn't feature any items which would contain the relevant information. I don't really know, why this is.

Retrieve channel's info using youtube data API

I want to fetch Youtube channel information e.g. total number of subscribers, language, info tab etc. What's the endpoint to do so if I have only my API key and channel id.
Figured out the answer, following is the API call to fetch channel information.
https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&id=UCSJ4gkVC6NrvII8umztf0Ow&key=[API_KEY]
Google's API Doc
https://developers.google.com/apis-explorer/#search/youtube.channels.list/m/youtube/v3/youtube.channels.list
using of below link which i shared might be useful for your problem
https://developers.google.com/youtube/v3/docs/channels/list

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.

API v3's brandingSettings inconsistently returning data

YouTube recently released the new brandingSettings return object in to the response of /channel/list, but it seems very inconsistent in returning data.
What are the situations where that will return data?
Is it only returned for YouTube Partner API accounts? I've been testing with both, but seem to get some of it for authenticated accounts using non-Partner keys.
Can I only get the full data set (image, channel, hints, ...) if the partner API account is a manager of the requested channel?
Is it limited to users using the new channel layout?
I'm just getting a very sparse data when testing it on both channels I have authorized, authorized and managed, and public, so any information on this would be very helpful.
https://developers.google.com/youtube/v3/docs/channels#properties
The brandingSettings part is supported for all types of channels, and should be modifiable when you're authorized as the channel itself, or via delegation using the onBehalfOfContentOwner= parameter. You can retrieve it's current settings using youtube.channels.list(part='id,brandingSettings', mine=true), make changes to the fields, and then pass in the modified JSON to youtube.channels.update(part='id,brandingSettings')
I'm fairly sure that only the latest channel layout is supported.
The one field that can't be updated is the channel title, as that needs to be changed via Google+ for linked channels (and the decision was made not to make it editable via the API for non-linked channels).

YouTube Analytics API Questions

I'm new to the YouTube Analytics API, and had a couple of questions:
In order to retrieve Analytics reports, I have to specify the channel ID for the "ids" parameter. How do I find the channel ID for the OAuth-authenticated user? I saw in the Sample Application that I can call Channels.list method in the Data API (V3) and use the "mine=true" parameter. Is this guaranteed to return a single channel? If not, how do I know which channel is the right one? What's the recommended way of finding a user's channel ID?
Once I have the channel ID, I can begin querying for Analytics data. I'd like to query the "views" metric for the channel for the entire history of that channel. The question is, how do I know how far back to query? Is there a channel start date? The Channels.list method mentioned above doesn't return the snippet.publishedAt date for my channel so that doesn't seem to be a reliable way. How else do I know when to stop? I guess I could query back until 2005 or so when YouTube was founded but that seems like a bad approach. Any suggestions?
The Analytics API supports reports for channels as well as content owners. Once a user authenticates via OAuth, how do I know if that account is a regular YouTube account vs a CMS content owner account?
Any help would be greatly appreciated!
The recommended approach is to do a channels.list(mine=true). The first result returned will be the channel corresponding to the currently authorized user. (channels.list() returns a list of channels because there are other combinations of request parameters that could result in more than one channel being returned.)
Going back to some arbitrary date in the past should be harmless. 2005, 2000, etc. The YouTube Analytics backend should know how to properly deal with that, and you'll obviously only get stats that date back to the first views associated with your channel.
The value of the ids= parameter tells the API whether you want to do a report against a channel associated with the current authorized user (ids=channel==UC...) or against channels/videos that you have access to as a CMS content owner (ids=contentOwner==CONTENT_OWNER_NAME).

Resources