user4599
user4599

Reputation: 95

crawling all comments on a youtube video

I am trying to crawl all the comments on a YouTube video

I am using this HTTP request:

https://www.googleapis.com/youtube/v3/commentThreads?key=AIzaSyBAcQUU5I4FElmsYVK0irkDPVGQ_OLLkO0&textFormat=plainText&part=snippet&videoId=K9vFWA1rnWc&maxResults=100

But the problem is that I need all the comments and it gives only 100 comments. The YouTube API3.0 doesn't allow me to increase the maxResults value to more than 100. Is there any solution to this?

Upvotes: 0

Views: 2289

Answers (2)

Anantha Raju C
Anantha Raju C

Reputation: 1897

The maxResults parameter specifies the maximum number of items that should be returned in the result set. Acceptable values are 0 to 50, inclusive. The default value is 5.

if a json response has more values than the maxResults, then the JSON response also has a parameter called pageToken. 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.

https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&allThreadsRelatedToChannelId=UC6KKh6eK3DIBMznzBiA4XOw&key=[API_KEY]&maxResults=2

in the above URL's JSON response you will find the nextPageToken which you must use add to the above URL the next time you send a GET request in order to get the remaining content.

Upvotes: 1

johnh10
johnh10

Reputation: 4185

The results will return a nextPageToken and you use that to get the next page of comments. See https://developers.google.com/youtube/v3/docs/commentThreads/list#properties

Upvotes: 1

Related Questions