List All Videos On A Youtube Channel < SECURE – COLLECTION >
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
The mobile app interface is slightly condensed but follows a similar logic. list all videos on a youtube channel
The API cannot return all videos in one go. You must loop through "pages." You can run the following Python script (install pip install google-api-python-client first): videos = [] next_page_token = None while True:
import os
import csv
from googleapiclient.discovery import build