Get a List Of All YouTube Videos of a Channel Using Python

Here’s a script that I have written to get a list of all the YouTube videos of any channel you want.

I am providing you the code, you will need to change the API Key, Channel ID, etc. things as per your own use.

If you want to gather more data from the videos such as date, description, time, likes, comments, or whatever you want, you can do that by passing parameters.

You can check out the official guide for more instructions: YouTube API Reference

Here’s the working code

from apiclient.discovery import build

api_key = 'YOUR_OWN_API_KEY'
youtube = build('youtube','v3', developerKey=api_key)

channel_id = input("Enter Channel ID: ")

def get_channel_videos(channel_id):
    res = youtube.channels().list(id = channel_id,
    playlist_id = res['items'][0]['contentDetails']['relatedPlaylists']['uploads']

    videos = []
    next_page_token = None

    while 1:
        res = youtube.playlistItems().list(playlistId=playlist_id,
                                           pageToken = next_page_token,
        videos += res['items']
        next_page_token = res.get('nextPageToken')

        if next_page_token is None:

    return videos

videos = get_channel_videos(channel_id)
i = 1
for video in videos:
    print(f"{i}. {video['snippet']['title']}")
    i = i+1

The only method that you will need to import for this program to run is build from apiclient.discovery library.

Here’s the video demo of the script:

Thank you!