How can get all results from Youtube API (search API) response

后端 未结 2 2078
我寻月下人不归
我寻月下人不归 2020-12-08 08:32

Like the title. I do a request like this :

https://www.googleapis.com/youtube/v3/search?key=AIzaSyDuxczhyyvHWfxKuF3ygW9p0GWmKlvWLYc&part=id,snippet&         


        
相关标签:
2条回答
  • 2020-12-08 09:20

    YouTube imposes a soft limit of about 500. There is no direct way to get more than that through the API.

    Full details: https://code.google.com/p/gdata-issues/issues/detail?id=4282

    Relevant Excerpt:

    "We can't provide more than ~500 search results for any arbitrary YouTube query via the API without the quality of the search results severely degrading (duplicates, etc.).

    The v1/v2 GData API was updated back in November to limit the number of search results returned to 500. If you specify a start-index of 500 or more, you won't get back any results.

    This was supposed to have also gone into effect for the v3 API (which uses a different method of paging through results) but it apparently was not pushed out, so it is still possible to retrieve up to 1000 search results in v3—the last 500 of which are usually of bad quality.

    The change to limit v3 to 500 search results will be pushed out sometime in the near future. There will no longer be nextPageTokens returned once you hit 500 results.

    I understand that the totalResults that are returned is much higher than 500 in all of these cases, but that is not the same thing as saying that we can effectively return all X million possible results. It's meant as an estimate of the total size of the set of videos that match a query and normally isn't very useful."

    Updated - How to get around the 500 result max soft limit

    Use the filters 'publishedAfter' and 'publishedBefore' to break up your query into loops of queries by day/week/month until no more results are returned. Each periodic query should return less than 500 results each, but you'll get them all.

    0 讨论(0)
  • 2020-12-08 09:23

    There's documentation for channelId (still not for videoCategoryId) by the way

    https://developers.google.com/youtube/v3/docs/search/list#channelId

    Note: Search results are constrained to a maximum of 500 videos if your request specifies a value
    for the channelId parameter and sets the type parameter value to video, ...
    
    0 讨论(0)
提交回复
热议问题