YouTube Data API v3 Comment

I am trying to get a list of comments using the new V3 Data API with mixed results.

For some videos, you only receive part of the comments. I've noticed this on a few videos, but for this particular case, I'll be using video ID = U55NGD9Jm7M

You can find all comments for this video on the WebUI here: https://www.youtube.com/all_comments?v=U55NGD9Jm7M

At the time of posting, there were 5,499 comments for this video.

API results :

When requesting https://www.googleapis.com/youtube/v3/commentThreads?part=id,snippet,replies&textFormat=plainText&maxResults=100&videoId=U55NGD9Jm7M&key= {YOUR_API_KEY} I only get a count of 317 responses and comments in chronological order).

Study verification :

If you select "Top Comments" from the dropdown list, then scroll down and hit "More" again, you will get over 1000 comments (I stopped at about 1000).

If you select "Newest First" from the dropdown and repeat the process (more ... next ... next) you will find that there are about 317 comments before you can no longer comment.

I find it rather odd that there is a mismatch in the UI, but luckily there is an API with a UI part. Has anyone else noticed this? Is there a way to get the full text of all 5,499 comments?

Thank!

Jason

Follow-up 1

As a follow up, I was able to isolate one comment using View-> Source (Thread ID z12wzfzhtybgz13kj22ocvsz2unrtn1qj04) and get all the information from that comment in the API here: <a2> {YOUR_API_KEY})

It even mentions the correct VideoID the comment is associated with. However, when you request a video, this comment ID is not returned.

Follow-up Observation 2 I am updating the web interface of all comments and there was a significantly different list of comments that are returned

+4


source to share


1 answer


The call commentsThread.list

can return a maximum of 100 results (see. maxResults

In the documentation ). If you want more comments, you need to go from nextPageToken

what you get from your initial call to a subsequent API call.

For example:

https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&videoId=U55NGD9Jm7M&maxResults=100&key=API_KEY

      



gives you 100 comments while nextPageToken

- Cg0Qk9fa7fHgxgIgACgBEhQIARCY49LZ5eDGAhi4rNGIrZrGAhgCIGM

. If you include this token in a new API call like:

https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&videoId=Dlj6SUg9B04&&maxResults=100&nextPageToken=Cg0Qk9fa7fHgxgIgACgBEhQIARCY49LZ5eDGAhi4rNGIrZrGAhgCIGM&key=API_KEY

      

You get a completely different set of comments. You can double check this by specifying order=time

in both API calls. You will see that the earliest comment threads for both calls are different, and you will not find Thread ID comments for the other call results. To get even more comments, you take nextPageToken

from the new call results and do the same again (until the call gives you another one nextPageToken

, which means that you are on the last page and there are no more comments needed).

0


source







All Articles