How to get all list youtube channel by API? - youtube

How to get all list youtube channel by API? Popular, categories...
ex:
Music
Sport
News
BostonEnglish
etc

Im not sure if there's a category for Boston English. But, for the general categories you've mentioned like Music, News, Sports, there's definitely a way to do that. Use this list as video category guide.
Try this on your browser:
https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&videoCategoryId=17&maxResults=50&key=SERVER_API_KEY_HERE
It will show you a list of channels under Sports.
Just change the videoCategoryId=17 part depending on which category you like. So if it's music, use videoCategoryId=10 and so on. maxResults=50 is set to 50, meaning it will display 50 results per page

Related

order - viewCount is showing wrong results in "YouTube API v3"

I am trying to get videos of a particular channel (like :- Luis Fonsi) in highest views order. And I am passing order parameter to sort the response by viewCount
like :-
order=viewCount
URL :-
https://www.googleapis.com/youtube/v3/search?key=[MY-API-KEY]&channelId=UCxoq-PAQeAdk_zyg8YS0JqA&part=snippet,id&order=viewCount&maxResults=20000
When I try to run it then It is not sorting as I expected. I was expecting first song would be Despacito But It got another one which definitely don't have the highest views.
As mentioned in Youtube-API Documentation in search section.
viewCount – Resources are sorted from highest to lowest number of views.
It is not working like this.
I have tried many times but it is still not working.
Any help would be much Appreciated.
YouTube Data API v3 is broken on some aspects, if I were you, I would just retrieve all videos from the given YouTube channel and then sort them.
To do so:
Get the channel's uploads playlist id by using Channels: list with part=contentDetails.
Get the channel's videos by using PlaylistItems:
list
with playlistId=UPLOADS_PLAYLIST_ID (replacing
UPLOADS_PLAYLIST_ID with the one you just obtained).
Get each
video's view count by using part=statistics with Videos:
list.

Finding random youtube videos of a specific language with subtitles

i would like to crawl Youtube for videos of a specific language that contains subtitles/closed-captions(CC).
For example,
I want to crawl for 200 random English videos with English subtitles/(CC).
I want to crawl for 300 random Chinese videos with Chinese subtitles/(CC).
I want to crawl for 550 random Malay videos with Malay subtitles/(CC).
There's an api here that helps to extract transcripts, but the main bottleneck right now is that i have to go youtube to search for these videos and watch one by one to find out if they are indeed in the correct language, and if they really contain subtitles/CC.
An option is:
Use YouTube Data API - search request for search videos that contains subtitles; for that, use videoCaption parameter with value: closedCaption.
You might need use another parameters for reduce the search terms to specific topics or get certain desired results; for example, for the q parameter, use a search term that retrieves the desired results; also all parameters like: videoDuration, type = video, relevanceLanguage.
Once you got such results, copy/paste the videoId you got from the results of the request and use your web-crawler for get more videos and the related ones.
For anyone still struggling with this, and as per the YouTube Data API for videoCaption to work, you need to also set the type parameter's value to video:
If you specify a value for this parameter, you must also set the type
parameter's value to video.

YouTube API V3 - How to get ALL game live streams

I'm trying to get "ALL" game live streams from youtube using API.
The way I first used is through "Search.list" with parameters: https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=snippet&eventType=live&maxResults=50&type=video&videoCategoryId=20. But in this way when I try to iterate results using PageToken, I can only get around 100 results while in the API response I can see "totalResults" is around 2000. Then I came into this topic and realized that "Search.list" is actually kind of "ranking" algorithm instead of "fetch all data from DB", which means "totalResults" is just an estimated number of results.
Then I came to use "liveBroadcasts.list" but it returns no results: https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.liveBroadcasts.list?part=id&broadcastStatus=active&maxResults=50&_h=8&
And for other APIs, they either need channelId or other ids.
Is there any way to get all game live streams regardless of any ids?
According to Youtube Category ID list, Gaming resides on number 20 category. In case you want to try a different category in the future, instead of videoCategoryId=20, you can try videoCategoryId=31 - that's for Anime/Animation.
Try to run this on your browser to get all live streams:
https://www.googleapis.com/youtube/v3/search?part=snippet&eventType=live&type=video&videoCategoryId=20&regionCode=US&maxResults=50&key=SERVER_API_KEY_HERE

Top 100 youtube videos

Is there any way to have updated lists of top 100 videos of youtube by genre and/or by country!
Any kind of resources like json files or xml.
You'll want to use the chart parameter of the videos.list endpoint. Set the chart to mostPopular, and then include a regionCode parameter and videoCategoryId parameter for further narrowing down. For example,
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&chart=mostPopular&regionCode=UA&key={YOUR_API_KEY}
Will retrieve the 5 most popular videos in the Ukraine.
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&chart=mostPopular&maxResults=25&regionCode=DE&videoCategoryId=1&key={YOUR_API_KEY}
Will retrieve the 25 most popular videos in Germany that relate to Film/Animation. And so on.
Note that if you don't include a videoCategoryId parameter, it will return results from all categories. If you don't include a regionCode, it returns the most popular videos across all regions. You can only set videoCategoryId to a value that's valid in the region you're searching in (you can use the videoCategories.list endpoint to find valid categories for regions, languages, etc.)

Complex YouTube search query

I have to search in a subset of YouTube results. For example, the query should search for some song title that belongs to a set of artists. Is it possible to group expressions?
For example, I would like to find all videos titled Vogue by either Madonna or Rihanna. So the required query should like something like this:
(Madonna|Rihanna)+Vogue.
The problem with this query is that the results returned will include all the songs by Rihanna and Madonna and all the videos that have Vogue in the title. And this I don't want.
Is there any way to specify complex logical expression to YouTube search API?
Just be more precise with your logic and use:
madonna+vogue|rihanna+vogue

Resources