1

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.

stvar
  • 6,551
  • 2
  • 13
  • 28
  • 1
    Other than using the [`Search.list`](https://developers.google.com/youtube/v3/docs/search/list) API endpoint, there's no other way you could query the YouTube Data API for the info you need. – stvar Aug 29 '21 at 08:20
  • Keep in mind that not every channel has the "countryCode" or "localization" in its channel info, hence, the data might not be as expected. You have to rely in what YouTube provides and you have to stablish some criteria for filter the values as you require. – Marco Aurelio Fernandez Reyes Jul 08 '22 at 14:11

1 Answers1

2

Note that I implemented a very similar approach as below in my YouTube captions search engine.

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).

  1. 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.
  2. 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.
  3. 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.
  4. 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.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33