问题
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