Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to YouTube

Scalekit connector
Open markdown

The YouTube connector lets your AI agent act in each user's YouTube account. Each user signs in to YouTube once, and Scalekit stores and refreshes their tokens, so your agent never handles credentials. It comes with 45 tools.

Tools
45
What they doRead · write · destructive
19 · 18 · 819 read18 write8 destructive
Users sign in with
OAuth app
Your own Google app

What you can do

  • Search and read videos: search videos, channels, and playlists, and fetch video details and statistics
  • Manage your videos: update video titles and details, like or dislike videos, and delete videos
  • Manage playlists: create, update, and delete playlists, and add or remove videos
  • Moderate comments: read comment threads, post and edit replies, and approve, reject, or delete comments
  • Query analytics: pull views, watch time, subscribers, and revenue, and schedule daily reporting jobs
  • Run live streams: create live broadcasts and streams, bind them, and move broadcasts through testing and live

Setup

  1. Install the SDK

    Terminal window
    npm install @scalekit-sdk/node dotenv
  2. Set your credentials

    Add your Scalekit credentials to your .env file. Find values in app.scalekit.com > Developers > API Credentials.

    .env
    SCALEKIT_ENVIRONMENT_URL=<your-environment-url>
    SCALEKIT_CLIENT_ID=<your-client-id>
    SCALEKIT_CLIENT_SECRET=<your-client-secret>
  3. Create the YouTube connection

    In AgentKit > Connections, create a YouTube connection and copy its redirect URI. The name you give it is the connection_name your code passes. See Configure connections.

  4. Register a Google OAuth app

    YouTube connections use your own OAuth app. Register one with Google and add the redirect URI you copied.

    Then enter the app's Client ID and Client Secret on the YouTube connection.

    Console steps with screenshots

    Register your Google OAuth 2.0 credentials with Scalekit so it can manage the OAuth 2.0 authentication flow and token lifecycle for YouTube on your behalf. You’ll need a Client ID and Client Secret from the Google Cloud Console.

    1. Create an OAuth 2.0 client in Google Cloud

      • Go to the Google Cloud Console and select your project (or create a new one).

        Google Cloud Console welcome page
      • Search for OAuth in the top search bar. Select Credentials under APIs & Services.

        Searching for OAuth in Google Cloud Console
      • On the Credentials page, click + Create credentials and select OAuth client ID.

        Google Cloud Credentials page showing OAuth 2.0 Client IDs Create credentials dropdown with OAuth client ID option
      • Set the Application type to Web application and enter a Name (e.g., Scalekit).

        Create OAuth client ID form with Web application type and Scalekit name
      • Leave the Authorized redirect URIs section empty for now — you’ll add the Scalekit redirect URI in a later step.

    2. Create a connection in Scalekit

      • In Scalekit dashboard, go to AgentKit > Connections > Create Connection.

        Scalekit Agent Auth connections page
      • Search for YouTube and click Create.

        Searching for YouTube in Scalekit Create Connection
      • Copy the Redirect URI from the connection configuration panel. It looks like https://<SCALEKIT_ENVIRONMENT_URL>/sso/v1/oauth/<CONNECTION_ID>/callback.

        Configure YouTube Connection panel showing Redirect URI, Client ID, Client Secret, and Scopes fields
    3. Configure the redirect URI in Google Cloud

      • Back in the Google Cloud Console, open your OAuth 2.0 client (or continue from step 1).

      • Under Authorized redirect URIs, click + Add URI and paste the Scalekit Redirect URI.

        Google Cloud OAuth client with Scalekit redirect URI added
      • Click Create (or Save if editing an existing client). A dialog displays your Client ID and Client secret. Copy both values.

        OAuth client created dialog showing Client ID and Client secret
    4. Add credentials in Scalekit

      • In Scalekit dashboard, go to AgentKit > Connections and open the YouTube connection you created.

      • Enter your credentials:

        • Client ID — the Client ID from your Google OAuth 2.0 client
        • Client Secret — the Client secret from the dialog in step 3
        • Scopes — select the scopes your app needs (e.g., youtube.readonly, youtube, youtube.force-ssl, yt-analytics.readonly)
        Configure YouTube Connection panel filled with Client ID and Client Secret
      • Click Save.

  5. Authorize a user and make your first call

    quickstart.mts
    import { ScalekitClient } from '@scalekit-sdk/node'
    import 'dotenv/config'
    import { createInterface } from 'node:readline/promises'
    const scalekit = new ScalekitClient(
    process.env.SCALEKIT_ENVIRONMENT_URL,
    process.env.SCALEKIT_CLIENT_ID,
    process.env.SCALEKIT_CLIENT_SECRET,
    )
    const actions = scalekit.actions
    const connector = 'youtube'
    const identifier = 'user_123'
    // Generate an authorization link for the user
    const { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })
    console.log('Authorize YouTube:', link)
    const rl = createInterface({ input: process.stdin, output: process.stdout })
    await rl.question('Press Enter after authorizing...')
    rl.close()
    // Make your first call
    const result = await actions.executeTool({
    connector,
    identifier,
    toolName: 'youtube_analytics_groups_list',
    toolInput: {},
    })
    console.log(result)
    Terminal window
    npx tsx quickstart.mts

    Each user signs in once. See Authorize a user for the full flow and statuses.

Tools

Pass the exact name to execute_tool
Try in PlaygroundRequest a tool
  • youtube_analytics_group_items_listRetrieve a list of items (videos, playlists, channels, or assets) that belong to a YouTube Analytics group.Read-only

    List Analytics Group Items

    Retrieve a list of items (videos, playlists, channels, or assets) that belong to a YouTube Analytics group.

    Inputs

    group_idstringrequired
    ID of the group whose items to retrieve
    on_behalf_of_content_ownerstring
    Content owner ID on whose behalf the request is being made
  • youtube_analytics_groups_listRetrieve a list of YouTube Analytics groups for a channel or content owner.Read-only

    List Analytics Groups

    Retrieve a list of YouTube Analytics groups for a channel or content owner. Specify either id or mine to filter results.

    Inputs

    idstring
    Comma-separated list of group IDs to retrieve
    mineboolean
    If true, return only groups owned by the authenticated user. Required if id is not set.
    on_behalf_of_content_ownerstring
    Content owner ID on whose behalf the request is being made
    page_tokenstring
    Token for retrieving the next page of results
  • youtube_analytics_queryQuery YouTube Analytics data to retrieve metrics like views, watch time, subscribers, revenue, etc.Read-only

    Query YouTube Analytics

    Query YouTube Analytics data to retrieve metrics like views, watch time, subscribers, revenue, etc. for channels or content owners.

    Inputs

    end_datestringrequired
    End date for the analytics report in YYYY-MM-DD format
    idsstringrequired
    Channel or content owner ID. Format: channel==CHANNEL_ID or contentOwner==CONTENT_OWNER_ID
    metricsstringrequired
    Comma-separated list of metrics to retrieve (e.g., views,estimatedMinutesWatched,likes,subscribersGained)
    start_datestringrequired
    Start date for the analytics report in YYYY-MM-DD format
    currencystring
    Currency for monetary metrics (ISO 4217 code, e.g., USD)
    dimensionsstring
    Comma-separated list of dimensions to group results by (e.g., day,country,video)
    filtersstring
    Filter expression to narrow results (e.g., country==US, video==VIDEO_ID)
    include_historical_channel_databoolean
    Include historical channel data recorded before the channel was linked to a content owner
    max_resultsinteger
    Maximum number of rows to return in the response (maximum value: 200)
    sortstring
    Comma-separated list of columns to sort by. Prefix with - for descending order (e.g., -views)
    start_indexinteger
    1-based index of the first row to return (for pagination)
  • youtube_captions_listRetrieve a list of caption tracks for a YouTube video.Read-only

    List Captions

    Retrieve a list of caption tracks for a YouTube video. The part parameter is fixed to 'snippet'. Requires youtube.force-ssl scope.

    Inputs

    video_idstringrequired
    ID of the video to list captions for
    idstring
    Comma-separated list of caption track IDs to filter results
  • youtube_channels_listRetrieve information about one or more YouTube channels including subscriber count, video count, and channel metadata.Read-only

    Get Channel Details

    Retrieve information about one or more YouTube channels including subscriber count, video count, and channel metadata. You must provide exactly one filter: id, mine, for_handle, for_username, or managed_by_me. Requires a valid YouTube OAuth2 connection.

    Inputs

    partstringrequired
    Comma-separated list of channel resource parts to include in the response
    for_handlestring
    YouTube channel handle to look up (e.g., @MrBeast). Use instead of id, mine, or for_username.
    for_usernamestring
    YouTube username of the channel to look up (legacy). Use instead of id, mine, or for_handle.
    idstring
    Comma-separated list of YouTube channel IDs. Use instead of mine, for_handle, or for_username.
    managed_by_meboolean
    Return channels managed by the authenticated user (content partners only). Use instead of id, mine, for_handle, or for_username.
    max_resultsinteger
    Maximum number of results to return (0-50, default: 5)
    mineboolean
    Return the authenticated user's channel. Use instead of id, for_handle, or for_username.
    page_tokenstring
    Token for pagination
  • youtube_comment_threads_listRetrieve top-level comment threads for a YouTube video or channel.Read-only

    List Comment Threads

    Retrieve top-level comment threads for a YouTube video or channel. You must provide exactly one filter: video_id, all_threads_related_to_channel_id, or id. Each thread includes the top-level comment and optionally its replies. Requires a valid YouTube OAuth2 connection.

    Inputs

    partstringrequired
    Comma-separated list of comment thread resource parts to include
    all_threads_related_to_channel_idstring
    Return all comment threads associated with a specific channel. Use instead of video_id or id.
    idstring
    Comma-separated list of comment thread IDs to retrieve. Use instead of video_id or all_threads_related_to_channel_id.
    max_resultsinteger
    Maximum number of comment threads to return (1-100, default: 20)default 20
    orderstring
    Sort order for comment threadsone of relevancetimedefault time
    page_tokenstring
    Token for pagination
    search_termsstring
    Limit results to comments containing these search terms
    video_idstring
    YouTube video ID to fetch comment threads for. Use instead of all_threads_related_to_channel_id or id.
  • youtube_comments_listRetrieve a list of replies to a specific YouTube comment thread.Read-only

    List Comment Replies

    Retrieve a list of replies to a specific YouTube comment thread. You must provide exactly one filter: parent_id or id. The part parameter is fixed to 'snippet'. Requires youtube.readonly scope.

    Inputs

    idstring
    Comma-separated list of comment IDs to retrieve. Use instead of parent_id.
    max_resultsinteger
    Maximum number of replies to return (1-100, default: 20). Cannot be used with id filter.default 20
    page_tokenstring
    Token for pagination to retrieve the next page of replies. Cannot be used with id filter.
    parent_idstring
    ID of the comment thread (top-level comment) to list replies for. Use instead of id.
    text_formatstring
    Format of the comment text in the responseone of htmlplainTextdefault html
  • youtube_live_broadcasts_listList live broadcasts owned by the authenticated user's YouTube channel.Read-only

    List Live Broadcasts

    List live broadcasts owned by the authenticated user's YouTube channel. Filter by broadcast status (active, upcoming, completed) or by specific broadcast IDs. Requires youtube or youtube.readonly scope.

    Inputs

    partstringrequired
    Comma-separated list of liveBroadcast resource parts to include in the response. Valid values: id, snippet, contentDetails, status.
    broadcast_statusstring
    Filter broadcasts by their current status.one of activeallcompletedupcoming
    idstring
    Comma-separated list of specific YouTube live broadcast IDs to retrieve. Use instead of broadcast_status.
    max_resultsinteger
    Maximum number of results to return (1-50, default 5).
    page_tokenstring
    Token for pagination.

Workflows

Google OAuth consent screen verification

Before you use your own Google OAuth credentials in production, understand what end users see on Google’s consent screen when they authorize a connected account.

Audience typeConsent screen behaviorWhen to use
InternalShows your App Name and logo from Branding settingsOnly users in your Google Workspace or Cloud Identity organization can authorize the connector
ExternalShows {env_name}.scalekit.dev until Google verifies your appAny user with a Google account can authorize the connector

Why External is required for most AgentKit connectors:

  • Internal restricts authorization to users in your Google Workspace or Cloud Identity organization. Users with @gmail.com or other Google accounts outside your organization cannot complete OAuth.
  • External is required when end users outside your organization authorize tool access through connected accounts.
  • Organization-managed OAuth clients follow the same rules as personal or developer OAuth clients. Switching to an org-owned client does not bypass Google verification.
  • Until Google completes verification of your External app, users see scalekit.dev on the consent screen. After verification, your App Name and logo appear.

During development:

  • Add Test users under APIs & Services → OAuth consent screen while publishing status is Testing.
  • On unverified apps, users can click Advanced → Go to app (unsafe) to proceed during testing.
  • Google Workspace admins may need to allowlist your OAuth client.

For Google’s verification requirements and timeline, refer to Google’s OAuth consent screen verification guide.