How to Extract YouTube Comments Using Youtube API - Python Last Updated : 03 Aug, 2023 Comments Improve Suggest changes Like Article Like Report Prerequisite: YouTube API Google provides a large set of API’s for the developer to choose from. Each and every service provided by Google has an associated API. Being one of them, YouTube Data API is very simple to use provides features like – Search for videosHandle videos like retrieve information about a video, insert a video, delete a video etc.Handle Subscriptions like lists all the subscriptions, insert or delete a subscription etc. In this article, we will discuss How to Extract YouTube Comments and reply using Google YouTube API in Python. Understand step by step implementation:- Retrieve YouTube Video ResultsHere we will use commentThreads, list, execute method, it will give the list of comment and repliesInside list method, pass snippet and replies in part property and in videoId property pass video id of video URL Python3 # creating youtube resource object youtube = build('youtube','v3', developerKey="Enter API Key") # retrieve youtube video results video_response=youtube.commentThreads().list( part='snippet,replies', videoId="Enter Video ID" ).execute() Iterate through each Video Response and fetch comments and repliesThe data comes in dictionary format, each comment data has reply count number, if reply count number is zero means no reply on that commentif count is greater than zero then we are iterating each reply and get text.nextPageToken contain the next data, here we are checking if nextPageToken has no value it means value is None, loop end, else loop will continue. Below is the full implementation: Python3 from googleapiclient.discovery import build api_key = 'API KEY' def video_comments(video_id): # empty list for storing reply replies = [] # creating youtube resource object youtube = build('youtube', 'v3', developerKey=api_key) # retrieve youtube video results video_response=youtube.commentThreads().list( part='snippet,replies', videoId=video_id ).execute() # iterate video response while video_response: # extracting required info # from each result object for item in video_response['items']: # Extracting comments comment = item['snippet']['topLevelComment']['snippet']['textDisplay'] # counting number of reply of comment replycount = item['snippet']['totalReplyCount'] # if reply is there if replycount>0: # iterate through all reply for reply in item['replies']['comments']: # Extract reply reply = reply['snippet']['textDisplay'] # Store reply is list replies.append(reply) # print comment with list of reply print(comment, replies, end = '\n\n') # empty reply list replies = [] # Again repeat if 'nextPageToken' in video_response: video_response = youtube.commentThreads().list( part = 'snippet,replies', videoId = video_id, pageToken = video_response['nextPageToken'] ).execute() else: break # Enter video id video_id = "Enter Video ID" # Call function video_comments(video_id) Output: Let's verify the results: 3 Comments and 2 Replies Comment More infoAdvertise with us Next Article How to Extract YouTube Comments Using Youtube API - Python abhigoya Follow Improve Article Tags : Python python-utility python Practice Tags : pythonpython Similar Reads How to extract youtube data in Python? Prerequisites: Beautifulsoup YouTube statistics of a YouTube channel can be used for analysis and it can also be extracted using python code. A lot of data like viewCount, subscriberCount, and videoCount can be retrieved. This article discusses 2 ways in which this can be done. Method 1: Using YouTu 3 min read Extract Video Titles with the Youtube API in Python Extracting video titles from YouTube can be incredibly useful for various applications, such as data analysis, content creation, and trend tracking. The YouTube Data API provides a robust way to interact with YouTube's platform and extract this information. This guide will walk you through the proce 4 min read GUI to get views, likes, and title of a YouTube video using YouTube API in Python Prerequisite: YouTube API, Tkinter Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and e 2 min read Extract title from a webpage using Python Prerequisite Implementing Web Scraping in Python with BeautifulSoup, Python Urllib Module, Tools for Web Scraping In this article, we are going to write python scripts to extract the title form the webpage from the given webpage URL. Method 1: bs4 Beautiful Soup(bs4) is a Python library for pulling 3 min read How to download public YouTube captions in XML using Pytube in Python? Prerequisite: Pytube Pytube is a dependency-free lightweight Python library for downloading YouTube videos. There are various APIs to fetch metadata from YouTube. In this article, we are going to see how to download public YouTube captions in XML using Python. Before starting we need to install this 2 min read Python PRAW - Getting the score of a comment in Reddit In Reddit, we can post a comment to any submission, we can also comment on a comment to create a thread of comments. Any user can either upvote or downvote a comment, the net value is the score of the comment. Here we will see how to fetch the score of a comment using PRAW. We will be using the scor 2 min read How to write Comments in Python3? Comments are text notes added to the program to provide explanatory information about the source code. They are used in a programming language to document the program and remind programmers of what tricky things they just did with the code and also help the later generation for understanding and mai 4 min read Playing Youtube Video using Python In this article, we will see how we can play youtube video in python. In order to play youtube videos in python we need pafy and vlc module. Pafy is a Python library to download YouTube content and retrieve metadata. Below is the command to install pafy pip install pafy VLC : is a python library to 2 min read How to Make API Call Using Python APIs (Application Programming Interfaces) are an essential part of modern software development, allowing different applications to communicate and share data. Python provides a popular library i.e. requests library that simplifies the process of calling API in Python. In this article, we will see ho 3 min read How to extract image information from YouTube Playlist using Python? Prerequisite: YouTube API Google provides a large set of APIs for the developer to choose from. Each and every service provided by Google has an associated API. Being one of them, YouTube Data API is very simple to use provides features like â Search for videosHandle videos like retrieve information 2 min read Like