LowCode Bhai


LowCode Bhai


How to get YouTube Channel ID from URL using Python

Prateek's photo
ยทJan 22, 2023ยท
How to get YouTube Channel ID from URL using Python


As a content creator or marketer, analyzing a YouTube channel's statistics is extremely important. These statistics provide valuable insights into a channel's performance and can help inform decisions on how to improve the content, reach new audiences, and measure the success of marketing campaigns.

One can fetch all such key stats for a YouTube channel from the official API of YouTube. However, you need to have the ID of that channel in order to get the required data from the API.

In this article, we will guide you through the simple process of extracting a YouTube channel ID from its URL, using Python.


We will be using two python libraries in this code - requests (version 2.28.2) and bs4 (version 4.6.3)

# import libraries
import requests
from bs4 import BeautifulSoup

# YouTube Channel's URL
url = ""

# get html content from the URL
response = requests.get(url)
soup = BeautifulSoup(response.content,'html.parser')

# extract and print channel's ID
print(soup.find("meta", itemprop="channelId")['content'])

That's it! This is how you can get any YouTube channel's ID from its URL and use the ID to fetch more data from YouTube's Data API.

Share this