5

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!

user1810724
  • 83
  • 1
  • 1
  • 4
  • For any search I am doing, I am getting openSearch:totalResults as 100. This doesn't make sense because for the same search in youtube there are thousands of videos. Any idea what's going on? – user1810724 Apr 26 '13 at 03:28
  • Sorry I mistakenly took it as its returning 100 videos. Its not so. Go through the docs of youtube api deeply. https://developers.google.com/youtube/2.0/developers_guide_protocol_api_query_parameters#Searching_for_Videos – Meera Apr 26 '13 at 06:47
  • This is a bug, and is being tracked at https://code.google.com/p/gdata-issues/issues/detail?id=4460 – Jeff Posnick May 01 '13 at 21:07

6 Answers6

7

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.

jlmcdonald
  • 13,408
  • 2
  • 54
  • 64
1

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.

Meera
  • 1,031
  • 6
  • 25
  • Even using the URL you've posted is only returning 100 total results for me... are you seeing more than that? – jlmcdonald Apr 26 '13 at 06:21
  • And what is the value of the element? This is a bit curious if you're receiving different results for the same feed request ... – jlmcdonald Apr 26 '13 at 06:30
  • I guess you can't acces more than 50 through query cause now i got an exception when i set the max result to 100. And its in the api docs of youtube that the maximum size would be 50. I guess there is no other go – Meera Apr 26 '13 at 06:35
  • Here is a similar situation http://stackoverflow.com/questions/8355848/why-can-i-get-only-25-youtube-video-from-a-feed – Meera Apr 26 '13 at 06:38
  • something changed last week I guess. It was working fine till mid last week. – user1810724 Apr 26 '13 at 16:06
1

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

Ravendra Kumar
  • 1,072
  • 10
  • 29
0

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?

0

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.

Tulio Casagrande
  • 1,499
  • 1
  • 15
  • 20
0

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.

Benjamin
  • 144
  • 12