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®ionCode=US&maxResults=50&key=SERVER_API_KEY_HERE
Related
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.
I'm trying to use Youtube Data API for a project, the goal is seeking for a keyword in a channel and show the response to the user. I used the Search for "snippet" part and launched it querying for a specific keyword and specifing the channel id but the response didn't include all the videos that I was expecting. For instance, let's say that the channel has 10 videos with "c" charachter in the title, setting the q field with "c" value will return only one video.
On the other side, if I search for a whole word it returns some videos with that word on title and some other videos that doesn't have it, neither in description. The order criteria in this case seems to be ok (from the strongest match to the most weak), but I don't know if all of this is working fine.
Is this a normal behaviour or am I doing something wrong?
Setting an order on the search, the issue seems to be solved.
I am trying to search for "Food+Show" from two youtube channels. ABCNetwork and FoxBroadcasting. The query I gave is
http://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc&q=Food+Show&max-results=3&authors=ABCNetwork,FoxBroadcasting&prettyprint=true
The first result I got was id UKfLsIgJB1g where uploader is wafelsanddinges and not ABC or Fox. Please tell me why my query is not retuning correct result.
The parameter for the v2 data API is "author," not "authors." Unfortunately, fixing that won't solve the problem, as the retrieval of videos from a particular channel can only accept one author at a time. This is also true for v3 of the API.
The reason behind this is that the comma is treated as a concatenator, looking for a video that was published on FoxBroadcasting AND ABCNetwork (the use case for having multiple authors in that parameter is if you are retrieving activity feeds, in which case you want both feeds so having the comma serve as an AND is correct).
So for now, the only solution is two separate calls.
I'm trying to load the first 100 videos of a YouTube channel and I can only load 50 videos. I always get this error message
Max-results value is too high. Only up to 50 results can be returned per query.
and I'm using this URL.
http://gdata.youtube.com/feeds/api/users/shaytards/uploads?&max-results=100
I'm not sure if I need any kind of developer key to load 100 results. Even if you know a way to load videos 75-100 would be great but any help would be appreciated.
The Youtube data API requires you to set up your own pagination if you need to get more than 50 results. In this case, then, you would set max-results to 50 and do the query, then on your page have some sort of "next" button (or however you want to implement your pagination) that would trigger a new call (either through ajax, a new page, or whatever your own workflow is). This new call would be to the same data feed, but you'd append the parameter &start-index=51 so that you'd get 50 more results, numbered 51-100. You can continue on like this up to 1000 results.
See https://developers.google.com/youtube/2.0/reference#Paging_through_Results for more details.
In the YouTube Data API V3 it is a little different. Each search query returns a "nextPageToken" that can be used in a subsequent query for more results. Documentation: https://developers.google.com/youtube/v3/guides/implementation/pagination
Is there some way I can retrieve more than 100 results using YouTube API?
I can retrive upto 100 results using this query string:
https://gdata.youtube.com/feeds/api/videos?q=football&orderby=relevance&start-index=1&max-results=10&v=2
But when I try
https://gdata.youtube.com/feeds/api/videos?q=football&orderby=relevance&start-index=101&max-results=10&v=2
I get:
http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/"C0YFQHg9fyp7I2A9WhBVGUk."'>tag:youtube.com,2008:videos2013-04-26T01:51:51.667Zhttp://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/>Videos matching: footballhttp://www.youtube.com/img/pic_youtubelogo_123x63.gifhttps://www.youtube.com'/>http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos?v=2'/>http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/batch?v=2'/>https://gdata.youtube.com/feeds/api/videos?q=football&start-index=101&max-results=10&orderby=relevance&v=2'/>https://gdata.youtube.com/feeds/api/videos?alt=atom-service&v=2'/>https://gdata.youtube.com/feeds/api/videos?q=football&start-index=91&max-results=10&orderby=relevance&v=2'/>YouTubehttp://www.youtube.com/http://gdata.youtube.com'>YouTube data API10010110
From what I understand, you can get 999 results using YouTube search API. Why is this limited to 100 here? Is there a workaround for me to get more than 100 results?
Thanks!
I can't speak to whether or not something has changed internally that is now capping totalResults at 100, but it seems to be a pretty common problem across the board today. However, if you were to try using v3 of the API, this wouldn't be an issue: for example, this query:
https://www.googleapis.com/youtube/v3/search?q=football&part=id&key=YOUR_DEVELOPER_KEY
Will give you many, many more total results. With v3, you can set the maxResults parameter up to 50 videos returned for each response, and then paginate through the responses by setting the pageToken parameter to whatever the "nextPageToken" attribute of a given response is.
Try like this https://gdata.youtube.com/feeds/api/videos?q=football&orderby=relevance&v=2
It will take the default size. When you use the start index and size you are using the pagination mechanism. I guess thats the problem here. And misfortune is that Google youtube API supports only max of 50 videos per query. Its there in the docs. 999 videos are the total videos that can be in a video feed. Not the number of videos it would query out. Dont mistakenly take it as it would return you all the videos. You have to use pagination with start index and size inorder to go through all the videos.
you can use this url
https://www.googleapis.com/youtube/v3/search?q=football&part=id&key=YOUR_DEVELOPER_KEY&max-results=150
and you easily get more than 100 results
I'm confused by this same issue - video search queries with start-index > 100 do not return any results:
http://gdata.youtube.com/feeds/api/videos?v=2&q=skateboarding+dog&max-results=50&start-index=101
and queries with a start-index < 100 return only the number of videos up to 100:
http://gdata.youtube.com/feeds/api/videos?v=2&q=skateboarding+dog&max-results=50&start-index=90
gives you 10 videos.
Shouldn't you be able to access results beyond the first 100 returned by the search?
There's a caching/escalating issue for pagination.
Check this answer here.
The correct way to page through a feed is to make the first request
for the feed without a start-index, and then check to see whether
there's a <link rel="next'...> and if so, use that URL to retrieve the
next page of a feed.
I discovered that if you put a small pause between each pagination call to API, it returns 400 results, it's mean 1 call per page putting 2 second between each call. It works for my. If you wuould like get more it, you have to close the connection to API and try again one or two minutes later.