List All Videos On A Youtube Channel File
videos = []
next_page_token = None
while True:
playlist_url = f"https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=uploads_playlist_id&key=API_KEY"
if next_page_token:
playlist_url += f"&pageToken=next_page_token"
data = requests.get(playlist_url).json()
for item in data["items"]:
video_id = item["snippet"]["resourceId"]["videoId"]
title = item["snippet"]["title"]
url = f"https://youtube.com/watch?v=video_id"
videos.append("title": title, "url": url)
next_page_token = data.get("nextPageToken")
if not next_page_token:
break
| Method | Requires API Key/OAuth | Completeness | Robustness | TOS-compliance | Best for |
|---|---:|---:|---:|---:|---|
| YouTube Data API | Yes (API key or OAuth) | High (public videos) | High | Yes | Production, analytics, automation |
| RSS feed | No | Low–Medium (recent uploads) | Medium | Yes | Quick checks, light integrations |
| HTML scraping / browse API | No (but may use embedded API key) | High (if done correctly) | Low–Medium | Risky | One-off extraction, unsupported cases |
| Third-party tools (yt-dlp) | No | High | Medium | Depends on tool | Command-line exports, downloads |
import requests
API_KEY = "YOUR_KEY"
CHANNEL_ID = "UCxxxxxx"
videos = []
next_page_token = None
while True:
playlist_url = f"https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=uploads_playlist_id&key=API_KEY"
if next_page_token:
playlist_url += f"&pageToken=next_page_token"
data = requests.get(playlist_url).json()
for item in data["items"]:
video_id = item["snippet"]["resourceId"]["videoId"]
title = item["snippet"]["title"]
url = f"https://youtube.com/watch?v=video_id"
videos.append("title": title, "url": url)
next_page_token = data.get("nextPageToken")
if not next_page_token:
break
| Method | Requires API Key/OAuth | Completeness | Robustness | TOS-compliance | Best for |
|---|---:|---:|---:|---:|---|
| YouTube Data API | Yes (API key or OAuth) | High (public videos) | High | Yes | Production, analytics, automation |
| RSS feed | No | Low–Medium (recent uploads) | Medium | Yes | Quick checks, light integrations |
| HTML scraping / browse API | No (but may use embedded API key) | High (if done correctly) | Low–Medium | Risky | One-off extraction, unsupported cases |
| Third-party tools (yt-dlp) | No | High | Medium | Depends on tool | Command-line exports, downloads |
import requests
API_KEY = "YOUR_KEY"
CHANNEL_ID = "UCxxxxxx"