Is it possible to access the actualStartTime value on another users livebroadcast using Youtube v3 api? - youtube-api

I am trying to access the snippet.actualStartTime value of a youtube livebroadcast, using the v3 API.
I have obtained an oauth2 token, and I am able to retrieve this data just fine, but only for my own channel.
I can't see anything on the documentation (https://developers.google.com/youtube/v3/live/docs/liveBroadcasts)
that indicates this information is private/restricted, it even has a specific flag for "mine", indicating that it is indeed possible to fetch it for other channels, but no matter what i try, i can't seem to gain access to it when providing a videoId from another channel.
Even if i try to query for only the "status" of the livebroadcast it returns an empty items[] array.
This is the request I'm using:
Axios.get(`https://youtube.googleapis.com/youtube/v3/liveBroadcasts?id=${videoId}&part=status`,
{
headers: {
Authorization: `Bearer ${token}`,
Accept: 'application/json'
}
})

YouTube Data API v3 Videos: list endpoint with part=liveStreamingDetails returns item/snippet/liveStreamingDetails/actualStartTime correctly for any YouTube channel.

Related

Youtube V3 Data API - Channels.list function not fetching all the channels

I am trying to get a list of youtube channels under one google account. But the api returns only one channel, although I have two channels inside my google account. Is there a way to get all the channels under one google account ? Is there any suggested workaround to this ? I have seen posts saying this is not possible, is this same now ?
Thanks
const service = google.youtube({ version: 'v3', headers: { Authorization: Bearer ${user.youtubeToken}}});
const result = service.channels.list({part: 'snippet,contentDetails,statistics', mine: true});

How to get YouTube channel info from google oath2 authorisation [duplicate]

For the app I'm building I want the end user to login using gapi OAuth2 and
from there I want the app to look for a playlist on their YouTube channel
and load it.
The getAuthInstance method returns an object with a Google username. However
for my own particular username, a query to find channel id by username
returns no results. From some browsing online, this is apparently an issue
with certain YouTube accounts.
Is there any workaround for this issue?
If you have a valid OAuth 2.0 authentication/authorization (for example, obtained by using GAPI), then it's quite simple the determine the authenticated user's channel ID using the Channels.list API endpoint queried with the parameter mine=true:
mine (boolean)
This parameter can only be used in a properly authorized request. Set this parameter's value to true to instruct the API to only return channels owned by the authenticated user.
Upon invoking the endpoint, the property id of the returned Channels resource contains the channel ID of the authenticated user.
For what concerns a Javascript GAPI (i.e. Google’s Client Library for Browser-side JavaScript) implementation, the code would look like shown below (for a broader context look into this sample source file from Google: analytics_codelab.js):
var channelId;
function loadAPIClientInterfaces() {
gapi.client.load('youtube', 'v3', function() {
getUserChannel();
});
}
function getUserChannel() {
var request = gapi.client.youtube.channels.list({
part: 'id',
fields: 'items(id)',
mine: true
});
request.execute(function(response) {
if ('error' in response) {
displayMessage(response.error.message);
} else {
channelId = response.items[0].id;
}
});
}
Note that the code above (unlike that in analytics_codelab.js) uses the fields request parameter for to obtain from the Channels.list endpoint only the channel's ID info (it is always good to ask from the API only the info that is of actual use).

Youtube Analytics API - How to get all the video stats for a given channel and date?

We got to build our own reporting database for our Youtube channel to measure the channel and video performance.
To support this, we implemented an ETL job to extract using Youtube Analytics API and used below python code to get the data.
def GetAnalyticsData(extractDate,accessToken, channelId):
channelId = 'channel%3D%3D{0}'.format(channelId)
headers = {'Authorization': 'Bearer {}'.format(accessToken),
'accept': 'application/json'}
url = 'https://youtubeanalytics.googleapis.com/v2/reports?dimensions={dimensions}&endDate={enddate}&ids={ids}&maxResults={maxresults}&metrics={metrics}&startDate={startdate}&alt={alt}&sort={sort}'.format(
dimensions='video',
ids=channelId,
enddate= extractDate,
startdate=extractDate,
metrics = 'views%2Ccomments%2Clikes%2Cdislikes%2Cshares%2CestimatedMinutesWatched%2CsubscribersGained%2CsubscribersLost%2CannotationClicks%2CannotationClickThroughRate%2CaverageViewDuration%2CaverageViewPercentage%2CannotationCloseRate%2CannotationImpressions%2CannotationClickableImpressions%2CannotationClosableImpressions%2CannotationCloses',
maxresults = 200,
alt ='json',
sort='-views'
)
return requests.get(url,headers=headers)
We hit this API everyday and get all the video metric and sorted by views in descending order.
This solved our need partially and it returns only 200 videos, if we specify maxResults more than 200, its return 400 error code.
The challenge is, how to get all videos for the given date and given channel?
Thanks in advance.
Regards,
Guna
I am not keen on YouTube analytics API, but it seems that you are looking for startIndex.
startIndex
integer
The 1-based index of the first entity to retrieve. (The default value is 1.) Use this parameter as a pagination mechanism along with the max-results parameter.

Youtube Data API(v3) doesn't return 'published_at' attribute at a specific channel

channel_id : UCBR8-60-B28hp2BmDPdntcQ
web : https://www.youtube.com/channel/UCBR8-60-B28hp2BmDPdntcQ
[request]
https://www.googleapis.com/youtube/v3/channels?id=UCBR8-60-B28hp2BmDPdntcQ&key={API_KEY}&maxResults=50&part=id%2Csnippet%2Cstatistics%2CbrandingSettings
We couldn't get this channel's published_at attribute by using Youtube Data API(v3). There is 'published_at' field in the return of the API, but a value is nil.
We aren't able to see that when this channel is published on the web(Is it able to hide such information?)
Does this problem only related to this channel?

Resolving two types of YouTube channel URLs in API v3

I'm taking a youtube url as user input.
The logic I have is as follows:
if(URL === link_to_video) then get video
else if( URL == link_to_channel) then get all_videos_of_channel.
I am doing this via JavaScript and using the YouTube API v3.
The problem is, it seems youtube has two types of URLs to youtube channels.
/channel/, eg:
www.youtube.com/channel/UCaHNFIob5Ixv74f5on3lvIw
/user/,
eg: www.youtube.com/user/CalvinHarrisVEVO
both the above links will take you to the same channel, but my current uploader code supports only /user/CalvinHarrisVEVO.
is there any way to make both the URLs behave similarly in terms of obtaining the channel videos?
One solution would be to parse the url and then apply this logic:
if there is `channel` in the url link
call the APIv3 with the **id** of the channel
Ressource : youtube.channels.list
else if there is 'user'
call the APIv3 with the **forUsername** of the channel
Ressource : youtube.channels.list
Check : https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list

Resources