« YouTube Data Scraper

YouTube API Comments Scraper

Download Data to Excel & CSV Files

Sign Up to Scrape YouTube Comments

Steve Spagnola
Written by Steve Spagnola
Last updated May 22, 2024

YouTube Comment Scraper

If you need to download YouTube comments from a particular video or channel, you can legally do this using the Official YouTube API List Comment Threads Endpoint for any public video URL or channel. Watch our video below to learn how to use the YouTube API with our no-code platform to export YouTube comments, or read on to learn more.

Compared to illegally web scraping YouTube comments directly from the YouTube website, you’ll be able to more reliably extract YouTube comments through the API without ever getting blocked - and it’s free! You can then process the users comments for data analysis, popularity tracking, sentiment analysis, or whatever other analytics project you can think of.

YouTube Comments API

You can start using the YouTube API List Comment Threads Endpoint without writing any code to see how it works, just play around with the API explorer on the right hand side as shown below.

YouTube API Exporter to Scrape Comments

You’ll want to enter snippet under the part parameter and you can scroll down to the videoId parameter and enter the ID of any public YouTube video. You can get the ID from the video link, for example the following URL https://www.youtube.com/watch?v=akOW_ZM4C4A would have a video ID of akOW_ZM4C4A:

Enter any Video ID and Hit Execute

You’ll then get back real data from the YouTube API containing a root JSON object and the comments for that video listed in the items key as a JSON list. See below for a sample of real data for our video akOW_ZM4C4A:

{
  "kind": "youtube#commentThreadListResponse",
  "etag": "C3OyhUNeUXSAN6gleeF8w3tEDvM",
  "nextPageToken": "Z2V...zhE",
  "pageInfo": {
    "totalResults": 20,
    "resultsPerPage": 20
  },
  "items": [
    {
      "kind": "youtube#commentThread",
      "etag": "unOQPQlLo8cS1sQp_3QloKSIOWU",
      "id": "UgxC_6bVzqL7FWtjnPR4AaABAg",
      "snippet": {
        "channelId": "UCrG9oWyDjv7fbtUeZWBX5bg",
        "videoId": "akOW_ZM4C4A",
        "topLevelComment": {
          "kind": "youtube#comment",
          "etag": "U7DpvS_JuFCvTFFxaM6B00oMDbE",
          "id": "UgxC_6bVzqL7FWtjnPR4AaABAg",
          "snippet": {
            "channelId": "UCrG9oWyDjv7fbtUeZWBX5bg",
            "videoId": "akOW_ZM4C4A",
            "textDisplay": "Please don’t take this video too seriously. While Resorts World did feel empty at first visit - compared to every other casino I saw that day - there are many positives to Resorts World that I did not cover.",
            "textOriginal": "Please don’t take this video too seriously. While Resorts World did feel empty at first visit - compared to every other casino I saw that day - there are many positives to Resorts World that I did not cover.",
            "authorDisplayName": "@StevesieTours",
            "authorProfileImageUrl": "https://yt3.ggpht.com/m7PO_RjLioTtdTQYpTak31kJACEn7kKs44Mlom-6aJEXpHPKoYOuqh971PdFcJ8-0sgeQaHQeA=s48-c-k-c0x00ffffff-no-rj",
            "authorChannelUrl": "http://www.youtube.com/@StevesieTours",
            "authorChannelId": {
              "value": "UCrG9oWyDjv7fbtUeZWBX5bg"
            },
            "canRate": true,
            "viewerRating": "none",
            "likeCount": 35,
            "publishedAt": "2022-11-24T20:38:10Z",
            "updatedAt": "2022-11-24T20:38:10Z"
          }
        },
        "canReply": true,
        "totalReplyCount": 5,
        "isPublic": true
      }
    }
  ]
}

Converting to CSV Files

You can then copy the JSON list and use a popular JSON to CSV Converter to download a CSV file containing the comments. This is a good way to get started for free, but if you need to scrape YouTube comments on a regular basis or have a large amount of comments to export, you can use our YouTube Video Comments Scraper to automatically download CSV files directly from the API response:

Automatically Convert YouTube JSON to CSV Files

Scraping 1,000s of YouTube Comments

By default, the API will only return 20 comments per request. You can change this using the maxResults parameter and specify up to 100 comments per request. This may be plenty if you’re scraping a small channel or less popular video, but if you’re scraping a larger channel or popular video, you’ll need to use pagination to get the full response.

Notice in our API response we saw the nextPageToken, which we can pass into the YouTube API List Comment Threads Endpoint‘s pageToken parameter to get the next page of comments and so on.

If this sounds like too much work, you can use our YouTube Video Comments Workflow to automate this process and scrape the full comments list for very popular videos (or a list of videos) into a single CSV file.

Scraping Comment Replies

If you also need to scrape the YouTube Comment Replies, make sure to set replies in the part parameter, so it should look something like snippet,replies to scrape both the original comment and replies. Our YouTube Video Comments Scraper does this for you automatically and will obtain up to a few hundred comment replies per comment:

Scraping YouTube Comment Replies

Scraping 1,000s of Comment Replies

The YouTube API List Comment Threads Endpoint doesn’t specify how many comment replies will be returned per comment, but if you find it not returning the full results, then you can see the YouTube API Comment Thread Endpoint which will look up all comment replies for the comment ID provided by the parentId parameter.

This endpoint also supports pagination, so if you have a comment with 1,000s of replies, you can use this endpoint to paginate through all the comment replies and be sure you scrape them all. We have a YouTube Comment Replies Workflow to automate this process as well, so you can enter a list of comment IDs and our service will scrape all of their replies, performing full pagination.

Scraping Comments by Channel

The List Comment Threads Endpoint also supports two options to collect comments by channel: allThreadsRelatedToChannelId and channelId. You can see the official docs for more information, but what these parameters do is actually a bit vague and we generally do not find them useful, but you’re free to try them out.

We instead suggest using the YouTube Channel Comments Workflow to collect all of the comments from a single channel. This will first look up all of the video IDs for a given channel and then look up all the comments and replies for all of those video IDs.

Finding the Channel ID

One little gotcha of using either of the above solutions is that they require a Channel ID, which can be tricky to find. Most YouTube URLs now just have the username in them, e.g. https://www.youtube.com/@StevesieTours no longer contains the Channel ID in the URL.

You can quickly get the channel ID using a free tool like the YouTube Channel ID Finder. Just provide the username or channel name and let the tool look up the channel ID for you, which you can now use with the YouTube API or with our YouTube Channel Scraper.

Find the YouTube Channel ID

Getting Your YouTube API Key

If you’d like to use our service for scraping YouTube comments or a similar software solution to access the YouTube API for scraping comments, you’ll need to have a YouTube API Key for programmatic access. See our article on How to get a YouTube API Key for more information.

Sign Up to Scrape YouTube Comments