Fetch the top trending YouTube videos using the official YouTube Data API v3. Requires a free API key (10,000 units/day free — each trending fetch costs 1 unit).
macOS / Linux (bash/zsh):
bash
export YOUTUBE_API_KEY=your_key_here
To persist across sessions, add that line to ~/.zshrc or ~/.bashrc.
Windows — Command Prompt:
cmd
set YOUTUBE_API_KEY=your_key_here
Windows — PowerShell:
powershell
$env:YOUTUBE_API_KEY = "your_key_here"
To persist in PowerShell across sessions, add it to your $PROFILE.
macOS / Linux:
bash
python3 scripts/fetch-youtube-trending.py # top 25, global
python3 scripts/fetch-youtube-trending.py FR # France
python3 scripts/fetch-youtube-trending.py US 50 # top 50, US
python3 scripts/fetch-youtube-trending.py US 25 10 # Music
python3 scripts/fetch-youtube-trending.py US 25 20 # Gaming
python3 scripts/fetch-youtube-trending.py US 25 25 # News & Politics
Windows (Command Prompt or PowerShell):
cmd
python scripts/fetch-youtube-trending.py
python scripts/fetch-youtube-trending.py FR
python scripts/fetch-youtube-trending.py US 50
python scripts/fetch-youtube-trending.py US 25 10
On Windows,
python3may not be in PATH — usepythoninstead. Both work if Python 3 is installed.
PositionDefaultDescription1_(none)Country code — omit for global chart225Number of videos (max 50)3(none)_Category ID — omit for all categories
IDNameIDName1Film & Animation22People & Blogs2Autos & Vehicles23Comedy10Music24Entertainment15Pets & Animals25News & Politics17Sports26Howto & Style20Gaming27Education28Science & Technology
For each video: rank, title, channel, duration, publish date, views, likes, comments, and a direct YouTube link.
https://www.googleapis.com/youtube/v3/videos?chart=mostPopularsnippet, statistics, contentDetailsurllib, json, re)YOUTUBE_API_KEY is set; if not, guide the user through the platform-specific setup abovepython3 scripts/fetch-youtube-trending.py [REGION] [COUNT] [CATEGORY] (use python on Windows if python3 is not in PATH)