Search code examples
javayoutubeyoutube-data-api

How do you set nextPageToken in YouTube Data API v3 using Java?


I'm trying to get all of the comment threads from a YouTube video. I need to know how to set the page token so that each successive call to The API gives me the next page of results. I have no problem getting the next page token. I just need to know how to set it/update it.


Solution

  • You've not specified the API endpoint you are using, but that should be CommentThreads (https://developers.google.com/youtube/v3/docs/commentThreads/list).

    The doc says that a call to CommentThreads may include the parameter pageToken (https://developers.google.com/youtube/v3/docs/commentThreads/list#pageToken). That is you need to use for to fetch one by one -- with separate API calls to the same endpoint -- the result sets you're interested in.

    From one API call to the next: get the nextPageToken from the former for to pass it to the latter as pageToken.