360 Secure SkillHub
360 安全技能中心

youtube-analytics

基于 YouTube Data API v3 的只读分析工具,可获取频道、视频与搜索结果统计,支持频道对比、视频表现分析和近期上传查询;结果默认不落盘,仅在显式开启时保存为 JSON。需要用户自备 API 密钥。

分类:数据
adamkristopher
adamkristopher
热度 66.59
最近更新 2026-11-29 02:53:25

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add adamkristopher/youtube-analytics
兼容性
通用兼容
联网要求
需要联网
数据出网
必须出网
Metadata
name
youtube-analytics
description
YouTube Data API v3 analytics toolkit: channel stats, video performance, channel comparisons, video and channel search, and recent uploads. Use when the user asks to analyze or compare YouTube channels or videos, or search YouTube. Read-only: uses the user's YouTube Data API key from .env and only public YouTube data. Saves nothing to disk unless SAVE_RESULTS=true.
version
1.1.1
homepage
https://github.com/adamkristopher/clawhub-skills/tree/main/youtube-analytics
metadata
{"openclaw":{"homepage":"https://github.com/adamkristopher/clawhub-skills/tree/main/youtube-analytics","primaryEnv":"YOUTUBE_API_KEY","requires":{"bins":["node","npm"],"env":["YOUTUBE_API_KEY"]},"envVars":[{"name":"YOUTUBE_API_KEY","required":true,"description":"YouTube Data API v3 key. Restrict it to the YouTube Data API in Google Cloud Console. Sent only to googleapis.com."},{"name":"YOUTUBE_DEFAULT_MAX_RESULTS","required":false,"description":"Default number of results for list queries (default 50)."},{"name":"SAVE_RESULTS","required":false,"description":"The only way to turn saving on - set to true to save results as JSON under ./results. Off by default. A call's save false can still skip saving."},{"name":"RESULTS_DIR","required":false,"description":"Where saved results go if SAVE_RESULTS is true. Default ./results in the working directory."}]}}

YouTube Analytics Toolkit

What this skill does with your data

  • Network: calls the YouTube Data API v3 (https://www.googleapis.com/youtube/v3) only. Read-only: it never posts, edits or deletes anything.
  • What's sent: the channel IDs, video IDs and search terms you ask about, plus your API key. Results are public YouTube data.
  • Credentials: YOUTUBE_API_KEY from .env in the working directory. In Google Cloud Console, restrict the key to the YouTube Data API v3 (and, ideally, to your IP). Keep .env out of version control.
  • Quota: each call uses your Google Cloud project's YouTube API quota.
  • Files: nothing is written unless you set SAVE_RESULTS=true; no function argument can turn saving on. Saved files are readable only by you (0600) and can only go in the results/ folders listed below.

Setup

Install the pinned dependencies from the lockfile:

cd scripts && npm ci --ignore-scripts

Configure credentials by creating a .env file in the project root:

YOUTUBE_API_KEY=AIzaSy...your-api-key
YOUTUBE_DEFAULT_MAX_RESULTS=50
# Optional: keep results on disk
# SAVE_RESULTS=true

Prerequisites: A Google Cloud project with the YouTube Data API v3 enabled. Get your API key from the Google Cloud Console.

Quick Start

User says Function to call
"Analyze this YouTube channel" analyzeChannel(channelId)
"Compare these two channels" compareChannels([id1, id2])
"How is this video performing?" analyzeVideo(videoId)
"Search YouTube for [topic]" searchAndAnalyze(query)
"Get stats for this channel" getChannelStats(channelId)
"Get this video's view count" getVideoStats(videoId)
"Find channels about [topic]" searchChannels(query)
"Show recent uploads from this channel" getChannelVideos(channelId)

Execute functions by importing from scripts/src/index.ts:

import { analyzeChannel, searchAndAnalyze } from './scripts/src/index.js';

const analysis = await analyzeChannel('UCxxxxxxxx');

Or run it with the project's pinned tsx (installed by npm ci):

cd scripts && npm start

Workflow Pattern

Every analysis follows two phases:

1. Analyze

Run API functions. Each call hits the YouTube Data API and returns structured data to you. Nothing is written to disk.

2. Summarize

Summarize the returned data for the user: tables, comparisons and insights. Write a summary file only if the user asks for one.

Saving (opt-in): only with SAVE_RESULTS=true in .env are results also saved as JSON in results/{category}/: named results as {sanitized_name}.json, others as YYYYMMDD_HHMMSS__{operation}.json.

High-Level Functions

Function Purpose What it gathers
analyzeChannel(channelId) Full channel analysis Channel info, recent videos, avg views per video
compareChannels(channelIds) Compare multiple channels Side-by-side subscribers, views, video counts
analyzeVideo(videoId) Video performance analysis Views, likes, comments, like rate, comment rate
searchAndAnalyze(query, maxResults?) Search + stats Search results with full video statistics

Individual API Functions

For granular control, import specific functions from the API modules. See references/api-reference.md for the complete list of 13 API functions with parameters, types, and examples.

Channel Functions

Function Purpose
getChannel(channelId) Get full channel details
getChannelStats(channelId) Get simplified stats (subscribers, views, videoCount)
getMultipleChannels(channelIds) Batch fetch multiple channels

Video Functions

Function Purpose
getVideo(videoId) Get full video details
getVideoStats(videoId) Get simplified stats (views, likes, comments)
getMultipleVideos(videoIds) Batch fetch multiple videos
getChannelVideos(channelId) Get recent uploads from a channel

Search Functions

Function Purpose
searchVideos(query, options?) Search for videos
searchChannels(query, options?) Search for channels

Results Storage (only if you opt in)

Off by default. Only with SAVE_RESULTS=true are results saved to results/ (or RESULTS_DIR) with this structure. Categories are fixed (channels, videos, search, summaries): other names are refused, and loadResult only reads files inside results/.

results/
├── channels/       # Channel data and comparisons
├── videos/         # Video data and analyses
├── search/         # Search results
└── summaries/      # Human-readable markdown summaries

Managing Results

import { listResults, loadResult, getLatestResult } from './scripts/src/index.js';

// List recent results
const files = listResults('channels', 10);

// Load a specific result
const data = loadResult(files[0]);

// Get most recent result for an operation
const latest = getLatestResult('channels', 'channel_analysis');

Tips

  1. Use channel IDs — Channel IDs start with UC (e.g., UCxxxxxxxx). You can find them in the channel URL or page source.
  2. Request summaries — After pulling data, ask for a markdown summary with tables and insights (saved to results/summaries/ only if you ask).
  3. Compare channels — Use compareChannels() to benchmark competitors side by side.
  4. Batch requests — Use getMultipleChannels() or getMultipleVideos() for efficient batch lookups.
  5. Search + analyze — searchAndAnalyze() combines search with full video stats in one call.