oytc: Open YouTube CLI

Read public YouTube data from the terminal, plus optional read-only analytics for your own channel.

What it does

oytc is a read-only client for YouTube Data API v3 and YouTube Analytics API. It can search and enumerate public YouTube resources, then return terminal tables, JSON, JSON Lines, or TSV. With optional OAuth, it reports analytics for the channel you authorize.

It deliberately has no uploads, edits, moderation, or other write operations.

Install

macOS / Linux

curl -fsSL https://davis7dotsh.github.io/open-yt-cli/install.sh | sh

The installer verifies SHA-256 checksums and needs no root access.

Windows (PowerShell)

irm https://davis7dotsh.github.io/open-yt-cli/install.ps1 | iex

Or download a ZIP from GitHub Releases. From source with Go 1.26+, run go install ./cmd/oytc or make build.

Getting started

  1. Create a Google Cloud project and enable YouTube Data API v3.
  2. Create an API key restricted to that API.
  3. Save and verify the key. The CLI prompts without echoing the secret.
oytc login
oytc status --check
oytc search "Go conference" --type video --limit 5
oytc channel get @GoogleDevelopers
oytc video stats dQw4w9WgXcQ --format json
oytc playlist items PLxxxx --all --limit 250

An API key is sufficient for every public-data command. For ephemeral or CI use, OYTC_API_KEY takes precedence over the saved key.

Optional: analytics for your channel

Configure a Google OAuth Desktop client, then authorize the read-only yt-analytics.readonly and youtube.readonly scopes:

oytc login --oauth
oytc analytics overview --by day --format json
oytc analytics video YOUR_OWN_VIDEO_ID --start 2026-01-01 --end 2026-01-31

Analytics reports only on the channel you authorize. Some protected Google accounts or Workspace policies require verification for the sensitive youtube.readonly scope.

Command reference

Use oytc --help, oytc <command> --help, or oytc <command> <subcommand> --help for exact flags in your installed release.

Credentials and upkeep

CommandPurpose
loginPrompt for, validate, and save a Data API key.
login --oauthRun browser OAuth for read-only channel and Analytics access.
status / status --checkShow non-secret credential state / also validate remotely.
logoutBest-effort revoke OAuth and remove stored credentials.
skills install / skill installAfter confirmation, install the bundled agent skill at ~/.agents/skills/oytc.
versionShow build and platform information.
update / upgradeChecksum-verified self-update; --check reports only and --version selects a tag.

Analytics — OAuth required

CommandPurpose
analytics report --metrics CSVRun a raw Analytics report; optional --dimensions.
analytics overview [--by day|month]Views, watch time, retention, and subscribers gained.
analytics video VIDEO_IDCore metrics for one owned video.
analytics traffic-sourcesViews and watch time by traffic source.
analytics demographicsViewer percentage by age group and gender.

Analytics reports accept --start, --end, --filters, --sort, and --limit; the default range is the last 28 complete UTC days.

Public YouTube data — API key

CommandPurpose
search [QUERY]Search videos, channels, and playlists using type, time, region, language, SafeSearch, and video filters.
channel get REFERENCE…Get channels by ID, @handle, or common YouTube URL.
channel activities CHANNELList public channel activity.
channel sections [CHANNEL]List sections, or fetch particular IDs with --id.
channel uploads CHANNELResolve and enumerate a channel’s public uploads playlist.
video get VIDEO_ID…Get metadata, content details, statistics, and status.
video stats VIDEO_ID…Get public counters.
video popularList the mostPopular chart, with optional region/category filters.
video trainability VIDEO_IDRead the public AI-trainability result; no API key or Data API quota needed.
playlist get PLAYLIST_ID…Get playlists by ID.
playlist list --channel CHANNEL_IDList a channel’s public playlists.
playlist items PLAYLIST_IDList entries, optionally filtering with --video.
comment get COMMENT_ID…Get comments by ID.
comment replies PARENT_COMMENT_IDList replies to a top-level comment.
comment threads --video VIDEO_IDList threads on a video.
comment threads --channel CHANNEL_IDList threads related to a channel.
comment threads --id THREAD_IDSGet specified threads.
subscription list --channel CHANNEL_IDList public subscriptions when exposed by the channel.
subscription list --id SUBSCRIPTION_IDSGet public subscriptions by ID.
live-chat list (--video VIDEO_ID | --chat-id ID)Fetch one finite page of active public messages.
live-chat stream (--video VIDEO_ID | --chat-id ID)Poll and deduplicate messages continuously; JSONL is the default.
category list (--region REGION | --id IDS)List video categories.
language listList interface languages.
region listList supported content regions.

Output and limits

All commands accept --format table|json|jsonl|tsv, --columns, --no-header, --quiet, and --timeout. Tables default on a terminal; JSON defaults when output is piped. Use --all deliberately on paginated commands and combine it with --limit for a hard cap.

Source and full documentation: davis7dotsh/open-yt-cli.