Strange behaviour Youtube v3 api

梦想与她 提交于 2019-12-02 11:39:18

问题


I am trying to page through all content of a Youtube channel by using the api:

https://www.googleapis.com/youtube/v3/search?channelId=UC5nc_ZtjKW1htCVZVRxlQAQ&part=snippet,id&order=date&maxResults=50&key=<myKey>

as I result I get:

{
 "kind": "youtube#searchListResponse",
 "etag": "\"CuSCwMPVmgi8taDtE2LV6HdgkN0/N3YNEZY0rLQ94onYIYp3nPLN57E\"",
 "nextPageToken": "CDIQAA",
 "regionCode": "CZ",
 "pageInfo": {
  "totalResults": 1381,
  "resultsPerPage": 50
 },
 "items": [ ...

all fine until here; items are present. however when i start paging through the results via the nextPageToken:

https://www.googleapis.com/youtube/v3/search?channelId=UC5nc_ZtjKW1htCVZVRxlQAQ&part=snippet,id&order=date&maxResults=50&key=<myKey>&pageToken=CJADEAA

Things start to get strange. After a couple of nextPageTokens there are no more items in the result, despite I wasn't even close to the total number of results (1381).

In my test after the 11th page, I got an empty result. I still get next and prev page tokens, also totalResults stays same, but no more items.


回答1:


Regardless of the total results found, the YouTube API has a soft limit of 500 results and will not return any more than that.




回答2:


Due to the results of the YouTube Search API being less accurate/related with more results provided, it was decided that the limit is to be set to 500 and no more. The issue can actually be seen here.



来源:https://stackoverflow.com/questions/36719895/strange-behaviour-youtube-v3-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!