oytc — read-only YouTube data and analytics CLI
oytc reads public YouTube Data API v3 resources with an API key and the authorized
channel's YouTube Analytics with read-only OAuth. It never writes. Revenue/content-owner
reports, private playlist/subscription access, moderation, uploads, and mutations remain
unsupported.
This skill assumes oytc is installed. Public commands need oytc login (or
OYTC_API_KEY); analytics ... needs oytc login --oauth. Verify both with
oytc status --check. Exit code 3 means the indicated credential must be configured or
reauthorized.
Core usage pattern
Always request machine-readable output: --format json (stable envelope with items,
nextPageToken, requests) or --format jsonl (one resource per line). Piped output
defaults to JSON already, but be explicit.
oytc search "topic" --type video --limit 10 --format json
oytc channel get @handle --format json # accepts UC… IDs, @handles, URLs
oytc channel uploads @handle --all --limit 200 --format jsonl
oytc video get VIDEO_ID --format json
oytc video stats VIDEO_ID_1 VIDEO_ID_2 --format json # counters are JSON strings
oytc playlist items PLAYLIST_ID --all --format jsonl
oytc comment threads --video VIDEO_ID --order relevance --format jsonl
oytc live-chat stream --video LIVE_VIDEO_ID --limit 100 # JSONL; REST polling fallback
# OAuth-only owner analytics
oytc analytics overview --by day --format json
oytc analytics video VIDEO_ID --start 2026-01-01 --end 2026-01-31 --format json
oytc analytics traffic-sources --format jsonl
oytc analytics demographics --format json
Pagination: --all follows pages, --limit N caps output, --page-token resumes.
Trim payloads with --parts and --fields when you only need specific properties.
Quota and safety
search costs 1 call from a small daily bucket (default 100/day) — batch reasoning
before searching, prefer channel uploads / playlist items for enumeration.
- Other list reads cost ~1 unit of a 10,000/day quota; exit code 5 = quota exhausted.
- Exit codes: 0 ok, 2 usage, 3 credentials, 4 not found/forbidden, 5 quota, 6 transient.
- Never print, log, or echo API keys, OAuth tokens, or the client secret.
oytc status
intentionally shows only a key fingerprint plus OAuth client ID/scopes/expiry. Do not
read the auth.json credential file.
- View/subscriber counters arrive as strings; keep them as strings to avoid precision loss.
References
1---2name: oytc3description: Query public YouTube data and an authorized channel's read-only analytics via the oytc CLI. Use for video/channel stats, searches, uploads, comments, live chat, watch time, traffic sources, and demographics.4---56# oytc — read-only YouTube data and analytics CLI78`oytc` reads public YouTube Data API v3 resources with an API key and the authorized9channel's YouTube Analytics with read-only OAuth. It never writes. Revenue/content-owner10reports, private playlist/subscription access, moderation, uploads, and mutations remain11unsupported.1213This skill assumes `oytc` is installed. Public commands need `oytc login` (or14`OYTC_API_KEY`); `analytics ...` needs `oytc login --oauth`. Verify both with15`oytc status --check`. Exit code 3 means the indicated credential must be configured or16reauthorized.1718## Core usage pattern1920Always request machine-readable output: `--format json` (stable envelope with `items`,21`nextPageToken`, `requests`) or `--format jsonl` (one resource per line). Piped output22defaults to JSON already, but be explicit.2324```sh25oytc search "topic" --type video --limit 10 --format json26oytc channel get @handle --format json # accepts UC… IDs, @handles, URLs27oytc channel uploads @handle --all --limit 200 --format jsonl28oytc video get VIDEO_ID --format json29oytc video stats VIDEO_ID_1 VIDEO_ID_2 --format json # counters are JSON strings30oytc playlist items PLAYLIST_ID --all --format jsonl31oytc comment threads --video VIDEO_ID --order relevance --format jsonl32oytc live-chat stream --video LIVE_VIDEO_ID --limit 100 # JSONL; REST polling fallback3334# OAuth-only owner analytics35oytc analytics overview --by day --format json36oytc analytics video VIDEO_ID --start 2026-01-01 --end 2026-01-31 --format json37oytc analytics traffic-sources --format jsonl38oytc analytics demographics --format json39```4041Pagination: `--all` follows pages, `--limit N` caps output, `--page-token` resumes.42Trim payloads with `--parts` and `--fields` when you only need specific properties.4344## Quota and safety4546- `search` costs 1 call from a small daily bucket (default 100/day) — batch reasoning47 before searching, prefer `channel uploads` / `playlist items` for enumeration.48- Other list reads cost ~1 unit of a 10,000/day quota; exit code 5 = quota exhausted.49- Exit codes: 0 ok, 2 usage, 3 credentials, 4 not found/forbidden, 5 quota, 6 transient.50- Never print, log, or echo API keys, OAuth tokens, or the client secret. `oytc status`51 intentionally shows only a key fingerprint plus OAuth client ID/scopes/expiry. Do not52 read the `auth.json` credential file.53- View/subscriber counters arrive as strings; keep them as strings to avoid precision loss.5455## References5657- [references/commands.md](references/commands.md) — condensed command/flag matrix58- [references/recipes.md](references/recipes.md) — common data-collection recipes59- Full project docs: https://github.com/davis7dotsh/open-yt-cli/blob/main/docs/commands.md