execute
Run JavaScript async function against a YouTube channel to chain Data, Analytics, Reporting API calls, transcripts, and search autocomplete with quota and confirmation gates.
Instructions
Run a JavaScript async function body against the user's YouTube channel. Call docs() first for recipes, quota rules, and gotchas. Use search() to look up method parameters.
The yt client:
yt.data..(params, body?, { confirm? }) YouTube Data API v3, e.g. yt.data.videos.list({ part: "snippet,statistics", id: ["a", "b"] })
yt.analytics.query(params) YouTube Analytics v2 reports.query; ids defaults to channel==MINE, dates to the last 28 days; returns { columns, rows: object[] }
yt.reporting..(params, body?) YouTube Reporting v1
yt.reporting.download(downloadUrl, { maxChars? }) CSV text of a report, default cap 50,000 chars
yt.paginate(fn, params, { max }) follows nextPageToken, returns items
yt.transcript(videoId, { lang? }) captions of any public video, no quota: { language, isGenerated, fullText, segments, available }
yt.suggest(query, { lang? }) YouTube search autocomplete, no quota
yt.upload(absPath, { snippet, status }, { confirm }) resumable upload from local disk
yt.setThumbnail(videoId, absPath, { confirm }) JPEG or PNG, 2 MB max
yt.quota() yt.auth.status()
Confirm gate: deletes, uploads, comments, thumbnails, captions, reporting jobs, live transitions, and anything that sets privacyStatus to public return a dry run ({ dryRun, effect, wouldCall, cost }) and send nothing unless the call passes { confirm: true } as its last argument. Show the user the dry run and get approval before confirming. Helpers in scope: formatDuration(iso), durationSeconds(iso), isLikelyShort(iso), toRows(analyticsResponse).
Chain many calls in one program and return a compact, aggregated result. Errors thrown by yt carry status, reason (e.g. quotaExceeded, authRequired, invalidParams), and message, and can be caught. The sandbox has no network, env, or filesystem; credentials stay on the host. Limits: 60s wall clock, 500 yt calls, 100 KB of returned JSON.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Async function body. Use return. | |
| quotaBudget | No | Max Data API units this run may spend. Calls past it throw quotaBudgetExceeded and send nothing. |