Sunny
Sunny

Reputation: 21

YouTube Data API v3 - Comment threads request doesn't return all comments

For certain videos the call to commentThreads does not return the complete set of toplevelcomments. For example the following call only returns 16 toplevel comments when in fact the video has over 3458 total comments, and the toplevel comments are clearly more than 16.

https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&videoId=h_9-3Fj3ZdI&key=[KEY]&maxResults=50

I have run into this issue on a couple of Videos and in both cases the result seems to break on a comment which is in fact missing from the web UI. I have looked around and and tried multiple ways (i.e. trying to skip using start-index etc) , but I haven't found a solution. You can verify the missing comment in the the above result: 'z131gd2gwqnby3lea23byp3yyt3pshcqb04'

Upvotes: 2

Views: 294

Answers (1)

Aaron Philipp
Aaron Philipp

Reputation: 91

I don't know if this is still important. But I can get all comments. You need to use the nextPageToken to get all comments (so more than your maxResults) and the comments-request to get the replies.

You can verify this in python as well. See the following code:

api_key = '...'

url = 'https://youtube.googleapis.com/youtube/v3/commentThreads?part=snippet&videoId=h_9-3Fj3ZdI&maxResults=100&key=' + api_key

response = requests.get(url=url).json()

print(response)

Upvotes: 0

Related Questions