How to get all comments on a YouTube video?
Asked Answered
H

5

46

Since Google has deprecated the YouTube v2 API, I cannot find a way to get all the comments from a video.

Is it possible to use a single, non-deprecated API (Google+, YT v3) to do that?

I am not concerned about maintaining threading.

Hawaiian answered 13/11, 2013 at 22:34 Comment(3)
If you want to use a tool I made to download comments as json youtuberandomcomment.comConni
@Conni Is your tool open source?Flaherty
@MichaelFreidgeim Nope.Conni
E
37

Believe me it works

https://www.googleapis.com/youtube/v3/commentThreads?key=******************&textFormat=plainText&part=snippet&videoId=kffacxfA7G4&maxResults=50

Key will be provided by the google developer console and 50 denotes 50 comments in form of a json, video id is the id of the video. For any type of queries comment below.

Energumen answered 18/9, 2015 at 21:31 Comment(4)
Indeed, that works. The name of the API section is quite misleading though.Alded
Does this also get replies to replies, not just replies to top-level comments?Loewi
Could I get the most up-voted comment without iteration ?Unwonted
This would only get top level commentsLamella
D
13

You can get only 100 at most at a time with the comments API. But you get a nextPageToken from the comment api response. Pass &pageToken={nextPageToken} to next api call, until the nextPageToken is undefined. Then you can get all comments if you like.

https://www.googleapis.com/youtube/v3/commentThreads?key={your_api_key}&textFormat=plainText&part=snippet&videoId={video_id}&maxResults=100&pageToken={nextPageToken}
Despairing answered 23/7, 2018 at 21:53 Comment(1)
But what if a page has more than 100 comments? Will this method get all the comments from the page?Whitecap
B
11

Apparently it is now possible to fetch comment threads.


(old answer)

Currently that's impossible with a first-party tool.

Source:

While v3 offers the majority of v2 functionality, there are currently a couple of tasks that can only be done with the older API. Specifically, applications that manage captions or that work with video comments still need to use the v2 API until modern equivalents are available. Our goal is to provide similar functionality well before the April 2015 shut-off date—please subscribe to this blog, the YouTube Data API v3 revision history page, or follow +YouTubeDev on Google+ to keep up-to-date. - http://apiblog.youtube.com/2014/03/committing-to-youtube-data-api-v3.html

TubeKit (YouTube crawling toolkit) might be of help to some.

Breakable answered 16/7, 2014 at 10:10 Comment(2)
Nice. It’s April 2015, and still no v3 way to get comments.Fall
The v3 API now supports comment retrieval developers.google.com/youtube/v3/docs/commentThreads/listRabbitfish
B
3

You can fetch all the comments using this API: https://www.googleapis.com/youtube/v3/commentThreads

The Youtube API v3.0 allows you the following parameters.

  1. textFormat - This parameter indicates whether the API should return comments formatted as HTML or as plain text. The default value is html.

  2. videoId - The Youtube Video ID you want to fetch comments for ( if you dont know your Youtube Video ID, you can get one from Youtube Video ID Finder )

  3. maxResults - The maxResults parameter specifies the maximum number of items that should be returned in the result set.

  4. pageToken - The pageToken parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken property identifies the next page of the result that can be retrieved.

Bostwick answered 8/11, 2019 at 6:36 Comment(0)
P
2

Through an Ajax call with jQuery:

$.ajax({
  dataType: "jsonp",
  type: 'GET',
  url: "https://www.googleapis.com/youtube/v3/commentThreads?key=PUT-YOUR-KEYXXXXXXX&textFormat=plainText&part=snippet&videoId=PUT-YOUR-VIDEO-ID",
  success: function(result){
    data = result;
    console.log(data);
    $('.data').text(data);
  }
});

To find PUT-YOUR-KEY(API key) ---> https://console.developers.google.com/apis/credentials then click on blue color button select API key option you can get

Polyhymnia answered 11/7, 2017 at 11:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.