Saliery
Saliery

Reputation: 119

How to get comments for Youtube video via API

I have an abstract question: How can I get comments (Not count of comments!) from Youtube via API fast? I mean in API side - I have a powerful server and fine code. But via API it's really painful long process.

I see only one way. There are steps:

  1. Make API request for get first page of comments;
  2. Save comments from step 1 and get nextPageToken from response;
  3. Make API request with pageToken option from step 2;
  4. So... Loop steps 2 and 3 while have a nextPageToken in response.

If we have 10-20-50 pages of comments it's painful... But if we have 1k+ pages of comments it's a HELL! And we have a limit for API requests... So for 2-3 popular videos we can spend the limit.

It looks like I can't find something :) It can't be so hard... Isn't it?

How do you get a comments from Youtube?

Upvotes: 0

Views: 839

Answers (2)

gvlachakis
gvlachakis

Reputation: 474

Well, the max comment retrieval limit is 100 each time right? So i guess you will have to go that way anyway. Have you tried any non-API solution? I found this but not sure if working better (or at all)?

Upvotes: 1

ReyAnthonyRenacia
ReyAnthonyRenacia

Reputation: 17651

Use CommentThreads.list to get all the comments in a certain video. The required parameters you need to provide are part, videoId and fields.

And to test this, go to Youtube API explorer Commenthreads.list and fill in the parameter for videoId (added the others for you). Then, click Authorize and Execute. All the comments of your video will be listed under textOriginal.

It's now up to you to implement this.

Upvotes: 0

Related Questions