Skip to content

Robj1925/youtube-zero-api-scraper

Repository files navigation

📺 YouTube Zero-API Scraper & Analytics CLI

Bypassing official YouTube Data API quota restrictions. Extract real-time channel metadata and watch metrics with zero API keys or limits.

FastAPI Go Module SQLite MCP

This repository packages a high-performance FastAPI Scraper Microservice and a compiled Go CLI / Model Context Protocol (MCP) Server. It allows developers, content creators, and AI Agents to scrape, store, search, and analyze real-time YouTube metrics in a local SQLite database completely quota-free.


🏗️ Architecture

graph TD
    User[Developer / AI Agent] -->|CLI Commands / MCP| GoCLI[Go CLI / MCP Server]
    GoCLI -->|SQLite Persistent Store| DB[(SQLite Database)]
    GoCLI -->|REST Requests| FastAPI[FastAPI Scraper Service]
    FastAPI -->|Dynamic HTML Scraping| YouTube[YouTube Public Pages]
Loading
  1. Scraping Layer (Python & FastAPI): Parses public YouTube HTML structure and dynamically extracts JSON payloads (ytInitialData) using brace-matching boundaries and recursive string evaluation. Supports rotating proxies for high-volume analytics.
  2. Storage Layer (SQLite): Saves scraped data in a structured, local SQLite database containing channels and videos, complete with indexes for high-speed offline query fallback.
  3. Client Layer (Go CLI & MCP): Unified client binary generated by the CLI Printing Press. Operates as a fast interactive CLI, a pipeable JSON command runner, or a standard Model Context Protocol (MCP) server for Claude, Cursor, and agentic workflows.

🚀 Quick Start

1. Launch the Scraper Service

Navigate to the scraper folder, install requirements, and run the FastAPI server:

cd scraper
pip install -r requirements.txt
uvicorn youtube_scraper:app --host 127.0.0.1 --port 8080

The API will be active at http://127.0.0.1:8080 with Swagger docs at /docs.

2. Build the Go CLI

In the repository root, build the Go CLI binary:

go build -o bin/youtube-scraper-pp-cli cmd/youtube-scraper-pp-cli/main.go

3. Fetch Channel Metrics

# Get basic channel analytics (subscriber count, video count, display details)
./bin/youtube-scraper-pp-cli channel Google

# Get recent long-form uploads and cache them locally
./bin/youtube-scraper-pp-cli channel videos get-channel Google

4. Fetch Detailed Watch Data

# Get real-time views, likes, and full description for a specific video
./bin/youtube-scraper-pp-cli video tfx2CjqtCUI

💻 CLI Commands & Formats

Global Query Flags

Customize response envelopes and automate scripting with native format flags:

  • Save as CSV: --csv
  • JSON Array Output: --json
  • Filter to Specific Columns: --select id,title,view_count
  • Bypass local request cache: --no-cache
  • Offline-Only Mode: --data-source local (Queries only local database)
# Example: Select only titles and view counts, and format as CSV
./bin/youtube-scraper-pp-cli channel videos get-channel Google --csv --select title,view_count

🤖 AI Agent & MCP Integration

This tool is optimized for consumption by AI Agents (like Claude Code, Cursor, or Custom LLM agents):

The --agent Flag

Append --agent to any command. This automatically sets:

  • Non-interactive mode (disables terminal prompt blocks).
  • Pure JSON output piped cleanly to stdout.
  • No ANSI color escapes or decorative text wrappers.
./bin/youtube-scraper-pp-cli channel Code-With-Robby --agent

Registered Model Context Protocol (MCP) Server

To expose these tools directly to Claude Desktop, register the compiled MCP binary:

  1. Build the MCP binary:

    go build -o bin/youtube-scraper-pp-mcp cmd/youtube-scraper-pp-mcp/main.go
  2. Add the server to your Claude Desktop config (e.g., ~/Library/Application Support/Claude/claude_desktop_config.json):

    {
      "mcpServers": {
        "youtube-scraper": {
          "command": "/absolute/path/to/bin/youtube-scraper-pp-mcp"
        }
      }
    }

🔒 No PII / Clean Environment

This repository has been fully audited to ensure:

  • Zero user-specific access credentials, API keys, or cookies are stored.
  • Zero personal identification paths, names, or private links are present in codebase definitions.
  • The local database is isolated under ~/.local/share/youtube-scraper-pp-cli/data.db to prevent workspace database leaks.

Generated and structured using the CLI Printing Press.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages