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

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.

Related

How can I get YouTube playlist views count?

Does anyone know how this website is able to get historical views data for YouTube playlists?
From my research, YouTube API doesn't even let you get the current playlist views (I might be wrong).
I am talking about the playlist views, not the views from videos that were added to the playlist (you can see the view count here for example, on the left side - on desktop).
How can we get access to this type of data?
One more time YouTube Data API v3 doesn't provide a basic feature.
I would recommend you to use my open-source YouTube operational API. Indeed by requesting the JSON document https://yt.lemnoslife.com/playlists?part=statistics&id=PLAYLIST_ID containing item["statistics"]["viewCount"] integer, your problem is solved.
You can request up to maxResults (currently 50) playlists separating playlist ids by a comma in id, example: https://yt.lemnoslife.com/playlists?part=statistics&id=PLAYLIST_ID_0,PLAYLIST_ID_1,...,PLAYLIST_ID_49
You can also request the title of the playlist by adding snippet to part, example: https://yt.lemnoslife.com/playlists?part=snippet,statistics&id=PLAYLIST_ID

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.

YouTube API is not giving accurate video results

Getting video in the results even though it didn't match query parameter(q)
The parameter i passed didn't exists in body,title,tags, But the video is relavant. Is API looks any other metadata of video.
For Example: i have given parameter as "mobile", this video https://www.youtube.com/watch?v=j8UNo3vRIB0 is coming as result, here video title and description not contain mobile as parameter
Latest data not coming consistently in youtube api
Some times latest data not coming in youtube data api.
For Example: i have given rule as "amazon". This video https://www.youtube.com/watch?v=6zygd1iW-f4 is showing in youtube website's latest videos but not coming in youtube api result.
Example query: https://www.googleapis.com/youtube/v3/search?part=snippet&order=date&q=amazon&maxResults=50&type=video&key=xyz
W.r.t. point (1), Youtube is working OK, since the content of that video is related to the keyword mobile (please convince yourself by watching the first couple of minutes of that video).
For what concerns your point (2), I cannot in any way make the Youtube site to produce the video 6zygd1iW-f4 near the top of its search result set for the query term amazon.
All in all, I deem your claims above unsustainable.
Please note that one cannot expect crisp results from Youtube when queried with such general terms as yours is. One should not expect Youtube's searching feature to work similarly to say a full-text search in single computer-stored database. There will always be a degree of fuzziness associated to querying Youtube for broad terms.
You are actually stumbling on a very tricky scenario. Your goal is to get the same results via the API that you also see on YouTube’s website, right?
First, make sure that you configured the search endpoint as identical to your YouTube user account as possible:
order: relevance
relevanceLanguage: Same as the language that you set in the menu of YouTube’s website (Use a ISO 639-1 2-letter Code)
regionCode: Same as the country that you set in the menu of YouTube’s website (Use a ISO 3166-1 2-letter Code)
With these settings you will see that the results will be quite similar. But still not identical. Not because the API is not working or is still not properly configured but rather because YouTube’s search results change all the time. Just do the same exact search on YouTube’s website just 10 seconds apart. You’ll see that you get different search results.

Output last and popular youtube videos on site ? any api?

I want to output last videos and popular videos of my youtube channel.
Is there any standart widget, api method for this?
Based on this answer, you can use the YouTube Data V3 API to get the uploads playlist ID, which you can then use to get the latest videos in that playlist. You can change the value of maxResults to return however many videos you want (from 0 to 50).
Use the search:list method to get your most viewed videos by specifying the channel ID and setting order=viewcount (not quite sure what you want when you say popular videos, you could also set order=rating to get the highest rated videos). This video might also help you out.

YouTube Preferred Channels Feed or API

I'm looking to programmatically discover the YouTube Preferred channels (Examples: https://www.youtube.com/channel/UCiq_aAkP44mMpRx8VvQiF6w/channels?shelf_id=5204494150831773367&view=49 and https://www.youtube.com/channel/UCpXBkrx5YWAe8I9nbmLK_fA/channels?) but the channel pages with their AJAX lists is all I've found. Obviously it would be much easier to crawl an API or an RSS feed (or even a static HTML page!) and I've yet to find anything like that with each of the YouTube Preferred channel ids.
Am I missing something? Do these preferred channel lists really only exist in this one form?
Edit #1: I have tried to use the YouTube Data API to pull these "Preferred" channels' playlists via /channel/lists, but both efforts were a bust as the /channel/list only returned the single top-level channel and the playlists were empty.
Edit #2: I tried the solution from this: Youtube api get the channels from the Featured channels module and it did not work (despite this question being tagged as a duplicate of it).
You can use the channelSections.list endpoint with the Google Preferred channel id (UCiq_aAkP44mMpRx8VvQiF6w), the preferred channel ids are in the contentDetails separated in 1% and 5% groups
Example: https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channelSections.list?part=contentDetails&channelId=UCiq_aAkP44mMpRx8VvQiF6w&_h=1&

Resources