YouTube API V3 difficulties while fetching top channels based on specific country - youtube-api

I want to fetch top channels (i.e top 10,100,150 channels) based on their subscribers and view count for specific country, How can I do that?
I have tried to use
https://www.googleapis.com/youtube/v3/search
but there is not any way found to fetch/search top YouTube channels with this API call, and not other way found for my need
Note: Tried regionCode parameter but that's not for filter the channels it fetching based on videos viewing in specific country
Thank you for your help in advance

What you want to do is not currently possible with this api.
search.list
Supports searching on a single region code
The Q paramater only does a fulltext search on the description and title of the video
There is no way to sort on either channels or subscribers.

Related

How do I get channel IDs for all YouTube channels in Japan?

I want to get channel IDs for all YouTube channels in Japan.
I tried to set the following parameters and call /search of YouTube Data API v3.
part: id
maxResults: 50
regionCode: jp
type: channel
pageInfo.totalResults in the API response is about 200,000 but actually I can only get 583 channel IDs.
583 is too little even if pageInfo.totalResults is an approximate value.
I would like to know how to get all the channel IDs in Japan, either by using the API or not.
I hope you will be able to provide the related information.
I tried to do almost the same for France. As said #stvar there isn't any appropriate endpoint to do so. However with patience and work we can make a kind of work around. My method only retrieves Japanese YouTube channels having indirectly publicly interacted with your starting set (see below).
Get a good starting set (in order to maximize the discover of the Japanese YouTube channels graph). I recommend you for instance to retrieve the top 100 Japanese YouTube channels sorted by view count by using SocialBlade.
For each channel discovered by the comments retrieved at step 3 (automatically) choose whether or not it is a Japanese YouTube channel. You can retrieve this piece of information if it is available for the channel in the "About" tab. To do it in an automatic way check whether or not snippet["country"] == "JP" in https://youtube.googleapis.com/youtube/v3/channels?part=snippet&id=CHANNEL_ID&key=YOUR_API_KEY If country isn't defined you can try to guess (automatically) whether or not it is a Japanese YouTube channel by making more complex checks see isFrench function. These checks are based on "About" tab and uploaded videos.
If the channel is interesting you (is Japanese) retrieve all comments (and so the YouTube channel about channel's videos and in the community tab using CommentThreads: list with part containing snippet and allThreadsRelatedToChannelId filter. If this method doesn't return any data because a video has disabled comments then retrieve the videos list and comments associated using (a) then CommentThreads: list with filter videoId. The approach (a) consists in getting the uploads auto-created playlist id of the YouTube channel by using Channels: list with contentDetails in part and then use PlaylistItems: list to retrieve all public videos uploaded on this YouTube channel. And if the YouTube channel contains more than 20 000 videos which is the upper limit for playlist size, use this script instead of (a). The script consists in faking requests done when browsing videos on a YouTube channel.
Then continue to dive into the Japanese YouTube channel graph by discovering Japanese YouTube channels through the comments found in your starting set and so on.
You can have a look for more details and some helping tools on my GitHub repository dedicated to the same approach for France (I was trying to list all comments let on French YouTube videos).
Of course you might need multithreading and group your YouTube Data API v3 request to reach maxResults upper limit in order to maximize your quota efficiency. Good luck.

Is there a way to get a list of Youtube videos sorted by view count

I am trying to collect a large list of YouTube's most watched videos for a data science application. I tried to use the YouTube Data API with the following query:
https://www.googleapis.com/youtube/v3/search&order=viewCount&type=video&regionCode=US&key=API_KEY,
but it does not seem to give me the same video ideas as in this list: https://en.wikipedia.org/wiki/List_of_most-viewed_YouTube_videos
Could someone tell me how I should do it?
Using the Search.list API endpoint is one way to search for the most viewed videos pertaining to a given region.
There's another endpoint -- Videos.list -- that, when queried with chart set to mostPopular, gives back:
chart (string)
The chart parameter identifies the chart that you want to retrieve.
Acceptable values are:
mostPopular – Return the most popular videos for the specified content region and video category.
As per the specification of videoCategoryId:
By default, charts are not restricted to a particular category.
Therefore, you may safely invoke Videos.list with chart=mostPopular and regionCode=US, without passing to it any videoCategoryId.
These two are the only API means that accomplish the task described by your post.

Query YouTube API for most liked videos

I am experimenting with YouTube's API, and I am trying to figure out how to return an ordered list of videos by the most number of likes.
I know I can access the number of likes using the video list query, but that is not going to get me what I need.
I need the search query response to have the videos already sorted by most liked.
Is there any query to the API that will do that?
Thanks,
Nathan
The YouTube API does not support ordering video search results by likes.
Order by rating order=rating and number of results with maxResults= For example:
fetch(`https://www.googleapis.com/youtube/v3/search?&channelId=${CHANNEL_ID}&maxResults=1&order=rating&type=video&key=${API_KEY}`)

How can I retrieve the country of a YouTube-channel using the YouTube API 3.0?

I need to analyze channels based on country. In the YouTube API 2.0, the country was listed in the channel feed (location-attribute). In 3.0, this attribute is gone.
Is there any hope of the location-attribute returning to the channel-feed (https://www.googleapis.com/youtube/v3/channels/)? Is there any workaround to retrieve country information? I already tried a suggestion on SO about the GuideCategories, which are completely useless for my purposes. I need to match country data to individual channels, not find a list of channels in a certain country.
Also, is there any way to request this as a feature to Google?

Channel Search in Youtube Data API within a particular category

I want to get all the channels within one particular category say "X".How can i achieve this using youtube data API?
Getting all the channels is easy and we can get these on the basis of searched keyword.
With the Youtube API v3 the channels can be filtered by the Freebase topic ID, besides keyword
https://developers.google.com/youtube/v3/docs/search/list

Resources