Reputation: 3315
We are planning to show a list of videos from our youtube channel on the website. I have checked the V3 API and it works fine. I followed the solution specified on this question.
The problem is how to browse through the list of videos uploaded over the years. The API will return a max 50 items on a single request. I want to give users a "Load More" link so that they can request the next batch (say next 50) of videos, in descending order of date uploaded (newest first). I couldn't find any parameters like page number or skip on the allowed list of parameters on the API call.
Upvotes: 0
Views: 290
Reputation: 5580
In the response body for videos list query you get a next page token that you can use to request the next batch of videos:
{
"kind": "youtube#videoListResponse",
"etag": etag,
"nextPageToken": string,
"prevPageToken": string,
"pageInfo": {
"totalResults": integer,
"resultsPerPage": integer
},
"items": [
video Resource
]
}
The nextPageToken response property as defined by the docs:
nextPageToken(string) The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set.
You use the nextPageToken that you receive in each response as a parameter to the pageToken parameter when making the next request. From the docs, the request parameter pageToken as defined by the docs:
pageToken(string) The pageToken parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved.
Upvotes: 2