Skip to main content

yt-metrics-cli

CI Python 3.12+ License: MIT Docs

CLI tool that analyzes YouTube channels and downloads video transcripts, generating engagement metrics and structured reports.

Problem

YouTube Studio gives you analytics for your own channels. If you want to compare multiple channels, benchmark engagement rates, or bulk-download transcripts for research, you're stuck with manual work or fragmented browser extensions.

yt-metrics-cli solves this: point it at a list of channels, get CSV data, engagement reports, and transcript files in one command.

Quick Start

# Install
pip install yt-metrics-cli
# or
uv tool install yt-metrics-cli

# Set your API key
export YOUTUBE_API_KEY=your_key_here
# Get one at: https://console.cloud.google.com/apis/credentials

# Create channels.yml
cat > channels.yml << 'EOF'
- custom_url: "@mkbhd"
- custom_url: "@veritasium"
EOF

# Analyze
yt-metrics channels

Features

Feature Description
Multi-channel analysis Analyze N channels in one run
Engagement metrics View rate, like rate, comment rate, viral detection
CSV export Raw data with all computed fields
Text reports Channel stats, trends, top/latest video URLs
Transcript download Multi-language with 3-level fallback chain
API resilience Exponential backoff on rate limits (403/429)

Usage

Analyze Channels

yt-metrics channels                        # Use defaults from .env
yt-metrics channels -c my_channels.yml     # Custom channel list
yt-metrics channels -n 100 -o ./reports    # 100 videos, custom output

Generates timestamped reports in output/<timestamp>/:

  • CSV — Raw data with all metrics per video
  • Channel Stats — Per-channel analysis with top 5 videos
  • Engagement Trends — Cross-channel comparisons and rankings
  • Best/Latest Videos — URL lists for quick access
  • README — Index explaining all generated files

Download Transcripts

yt-metrics transcript -v dQw4w9WgXcQ       # Specific video
yt-metrics transcript -v abc123 -l es,en    # Language preference

Engagement Metrics

Metric Formula Interpretation
Engagement Rate (likes + comments) / views * 100 Overall audience interaction
View Rate views / subscribers * 100 Reach beyond subscriber base (>100% = viral)
Like Rate likes / views * 100 Content satisfaction signal
Comment Rate comments / views * 100 Discussion engagement level

Configuration

All settings can be set via environment variables or .env file:

Variable Default Description
YOUTUBE_API_KEY (required) YouTube Data API v3 key
MAX_RESULTS_PER_CHANNEL 50 Videos to fetch per channel
OUTPUT_DIR ./output Report output directory
CHANNELS_FILE channels.yml Channel list file path
VIDEO_ID — Default video for transcript mode
TRANSCRIPT_LANGUAGES es,en Preferred transcript languages

Development

git clone https://github.com/mlorentedev/yt-metrics-cli.git
cd yt-metrics-cli
make install    # Create venv + install deps
make check      # Lock check + lint + typecheck + test
make build      # Full build

See CONTRIBUTING.md for details.

License

MIT

Documentation

Project-bound knowledge lives in docs/ (docs-as-code) — currently docs/lessons/, one file per lesson. The build/operate docs live in the repo; the published site is site/.

Working on this repo with an AI agent? Start at AGENTS.md — architecture, invariants, commands and the knowledge-placement rules.

Metadata

Release files for yt-metrics-cli 0.2.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yt-metrics-cli 0.2.8
File Size Uploaded Provenance
yt_metrics_cli-0.2.8.tar.gz 165.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for yt-metrics-cli 0.2.8
File Interpreter ABI Platform
yt_metrics_cli-0.2.8-py3-none-any.whl Python 3 none any Details

Total release size: 185.4 kB

Release files / yt_metrics_cli-0.2.8.tar.gz

Download URL yt_metrics_cli-0.2.8.tar.gz
Size 165.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5cc985976f5c284e3b53cc397e3be6f254ec95c9aa928c91ac0c0a2ec7af987a
BLAKE2b-256 checksum
How to use checksums
b41330d40765c025f4a6e7b1a4c01c7fb100aa83cafdd8e386d78535fb7f74a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Release files / yt_metrics_cli-0.2.8-py3-none-any.whl

Download URL yt_metrics_cli-0.2.8-py3-none-any.whl
Size 20.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d445d2c1bbebde1fc7cc62bc20d5c66159b3510afb9616c92ff5fa55fd33a05
BLAKE2b-256 checksum
How to use checksums
ae42f36c9f32778c9641c91e0336e236352af14464559f2161e2cf17513d2c6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Security for yt-metrics-cli 0.2.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for yt_metrics_cli-0.2.8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page