Get Video Information from ChannelD - youtube-api

I am looking for the json from where i can get information of video falls in specific channel(ChannelId is given). I tried below to get the same, but page not found showing.
https://www.googleapis.com/youtube/v3/search?key=***&channelId=UC39dDX5cE3WxN5ObmCBsCCQ
Or any other effective way to fetch the information?

Api version 3 returns only json in responses. You find information at https://developers.google.com/youtube/v3/docs/
Channel information returns a playlist-id of the uploaded videos for a channel.
But using search can work too (Replace YourApiKey with your own key):
https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&channelId=UC39dDX5cE3WxN5ObmCBsCCQ&maxResults=50&key=YourApiKey

Related

YouTube API v3 Search not returning all videos

I'm trying to retrieve all videos for a channel, and some are not being returned by the api. I cannot find anything in the spec that indicates why some would not be in the result set.
The call I'm making is:
https://www.googleapis.com/youtube/v3/search?type=video&key=__key_here__&channelId=UCxS2lX7728bTnmK1t21bYlA&part=id,snippet&maxResults=50&order=title
[To test this you'll need your own api key]
The first page of results is missing at least one video. The one from 8-15-2018, titled I LEARNED HOW TO DO A NEW TRICK!, which is located here, is not in the result set, even though it falls within the date range, and the first 50 results.
Does anyone know if this is a known issue?
I have verified that if I add the q parameter, with the video id, it will retrieve it.
You may refer with this link.
The API call that you should make if you want to get the videos in a channel is a youtube.playlistItems.list() with the playlistId of the "uploads" playlist for the channel. (This usually stars with UU..., but that's an implementation detail that might change in the future.
Here's an example of the call in the API Explorer.
Getting the same data via a search operation isn't guaranteed to return everything; the search index isn't a replacement for the backend data that you can obtain via the youtube.playlistItems.list() call. It's very much the same point raised in this blog post (though the focus there is on v2).
To summarize, to get all the uploads from a channel, you need to get the items from the uploads playlist for the channel using playlistItems.list on that playlist's ID rather than calling search.list on the channel ID.

YouTube API "mostPopular" requests doesn't seem to give updated results

It seems that the YouTube API doesn't give updated results for mostPopular videos in my country since few days.
Example:
This request (https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails&chart=mostpopular&regionCode=FR) doesn't give me the same videos results than the ones displayed directly on YouTube for the French most popular channel (https://www.youtube.com/channel/UCmzy72gDEpfXoFV9Xdtd0DQ). It seems that the results of this request is not updated since the 1th of february. Results was real time updated before this.
Does someone know if something is wrong with my API request, or if there are some issues with the YouTube API at this moment?
There is nothing wrong with your request. This is a known issue with the YouTube API reported here for Saudi Arabia (but also applicable to multiple regions), and another related issue here with regard to content from France.
Your best bet would be to follow up with the YouTube team on one of those defects, or potentially (and dangerously) scrape the YouTube site for the correct results.
Problem seems to be solved since 13th of february (maybe someone from Google have seen my post..)
YouTube Channels and chart=mostPopular parameter data are separate data entities, aka you will get different results. They may be related but there is no guarantee you will get the same data. To get the data that you want you may need to query for channel itself and its videos.
I got this information from the thread #Jal linked, there was an update by matthewc...#google.com a few days ago:
The most popular channel for Saudia
Arabia and
the mostPopular chart parameter in the video.list
call
are separate and distinct entities. If you'd like to get the content
of the most popular channel for Saudia
Arabia
please use the Data API video.list call to list the videos with the
channel ID (in this case "UCWY-_j1MCth6yf24m58Bh_Q") by setting the
items/snippet/channelId parameter.
My current concern right now is that there is supposedly a way to get video information from the videos.list endpoint using a channelId, which does not seem the case in the API Explorer. I will update my answer once I figure out what this person meant exactly.

Youtube get user uploads in php

I am trying to get the full list of videos uploaded by a user.
I am using the following url:
https://gdata.youtube.com/feeds/api/users/username/uploads?v2&alt=json
And using curl in php to get the contents.
But I am getting only 25 results. If I use the max-results, the max is 50.
What should I use in order to get the whole list?
After replacing 'username' with a valid name the response shows a url link for the next request in the response you get. Look for: {"rel":"next","type":"application/atom+xml","href":"https://gdata.youtube.com/feeds/api/users/username/uploads?alt=json&start-index=26&max-results=25"}
As you can see another parameter is added: 'start-index'. Which you also can add yourself
BTW. I assume you know there is a typing error in your example. You set the version parameter by using 'v=2' instead of 'v2'.
I suggest using YouTube Data API v3 for this purpose.
You can get to use PHP examples in YouTube API Samples project.

How do I use Youtube Data API V3 to fetch channel uploads using chanel's username?

I've explored most of this topic using the previous question How do I get a list of uploaded videos for a certain channel with the new YouTube Data API (V3)?, but I wanted some specifics that build upon the answer given.
Is it possible to use the channel's username without calling a search query to get the channel ID? I have an https request that can get a search list shown below, but I'd rather not waste API quotas when I know the exact channel username.
https://www.googleapis.com/youtube/v3/search?q={channel_username}&key={my_api_key}&part=snippet
My hack for this is just take a videoid from the channel and extract a uploader ID from there, but its not elegant and won't work if the upload is removed.
Also, once I've worked my way down to getting the uploads key, how can I get a json that shows all of the uploads and not just a list of 25? If I do have to recursively call pages of uploads, how can I do that?
Thanks.
I think that to get a channel, using the channel's username, the only option is to use the search, and the best strategy to minimize the use of quota is to use a cache, or save the channel ID.
For a full list of videos uploaded, as JSON, you can use contentDetails.relatedPlaylists.uploads (the ID of the playlist that contains the channel's uploaded videos) and retrieve the PlaylistItems, using pages with 50 items per page, and using the nextPageToken value to retrieve each page in the result set.
I've found the answer. The correct way to go about it is to query the site using the search, but directly state the type of list to respond with, in effect searching only channels. This is done by
https://www.googleapis.com/youtube/v3/search?q={search_term}&key={API_key}&type=channel&part=snippet
As you can see the type is channel. By searching with a search term of the exact channel username, you'll get a return list with the first item object as the channel, and you can store the channel ID and upload ID from there.
To update this answer, you need to recognise the "quota limits".
As such, to use the "search?q=[search]" will incur a 100 quota usage.
Better to use "channels?part=id&forUsername={username]" as is only a quota of 1.
Then you can use "channels?part=id,snippet ....... &id={channel_ID]" to grab all your data

Youtube API 2.0 Checking if a video is age restricted

I would like to check and see if a youtube video is age restricted. There are not many videos that are, but some are. I have been digging around in the youtube api documents and on the internet, but can't seem to find a way to detect this.
I am using the Youtube API V2 and only looking for one video at a time.
To check whether a video is (age) restricted in a given region, you can take a look at the media:rating attribute of the video entry, which is documented at
https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_media:rating
If you want to do a search and filter out videos that are age restricted, you can use the safeSearch=strict parameter:
https://developers.google.com/youtube/2.0/reference#safeSearchsp
I agree to Greg Schechter. The actual question was like if we have a video id (eg: In the link http://www.youtube.com/watch?v=RyDY0hiMZy8 the video id is RyDY0hiMZy8), how can we get the age restriction details based on that?
There is an API provided by Youtube to get the details based on the video id. For the above example the API link is:
http://gdata.youtube.com/feeds/api/videos/RyDY0hiMZy8?v=2&alt=json
But there is no information about the age restriction in the response.
Update on the above post:
In the API response from http://gdata.youtube.com/feeds/api/videos/tA4wytG3uh0?v=2&alt=json
we have a media$rating content coming and the data coming there can be compared with the rules mentioned in the link https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_media:rating
For non restricted videos, the media$rating value is not coming in the response. eg: in the link http://gdata.youtube.com/feeds/api/videos/RyDY0hiMZy8?v=2&alt=json
Any updates are welcome.
Age gating is not supported for embedded playbacks; so it's not something that is returned in the YouTube data api.
You can un-restrict those videos by following this link:
https://www.quora.com/How-do-you-change-the-settings-of-the-the-age-restrictrincts-on-my-YouTube-videos/answer/Doyle-Lorraine
Then your iframes should be back to normal.

Resources