KosmoKrator

data

YouTube CLI for AI Agents

Use the YouTube CLI from KosmoKrator to call YouTube tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

7 functions 7 read 0 write API key auth

YouTube CLI Setup

YouTube can be configured headlessly with `kosmokrator integrations:configure youtube`.

# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure youtube --set api_key="$YOUTUBE_API_KEY" --enable --read allow --write ask --json
kosmokrator integrations:doctor youtube --json
kosmokrator integrations:status --json

Credentials

Authentication type: API key api_key. Configure credentials once, then use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
api_key YOUTUBE_API_KEY Secret secret yes API Key

Call YouTube Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

kosmo integrations:call youtube.youtube_search_videos '{
  "query": "example_query",
  "type": "example_type",
  "max_results": 1,
  "page_token": "example_page_token",
  "order": "example_order",
  "published_after": "example_published_after",
  "published_before": "example_published_before",
  "region_code": "example_region_code"
}' --json

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations:youtube youtube_search_videos '{
  "query": "example_query",
  "type": "example_type",
  "max_results": 1,
  "page_token": "example_page_token",
  "order": "example_order",
  "published_after": "example_published_after",
  "published_before": "example_published_before",
  "region_code": "example_region_code"
}' --json

Agent Discovery Commands

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

kosmo integrations:docs youtube --json
kosmo integrations:docs youtube.youtube_search_videos --json
kosmo integrations:schema youtube.youtube_search_videos --json
kosmo integrations:search "YouTube" --json
kosmo integrations:list --json

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to YouTube.

youtube.youtube_search_videos

Read read

Search for videos, channels, or playlists on YouTube using keywords, filters, and sorting options. Returns matching results with snippet metadata.

Parameters
query, type, max_results, page_token, order, published_after, published_before, region_code, channel_id, video_duration, safe_search

Generic CLI call

kosmo integrations:call youtube.youtube_search_videos '{"query":"example_query","type":"example_type","max_results":1,"page_token":"example_page_token","order":"example_order","published_after":"example_published_after","published_before":"example_published_before","region_code":"example_region_code"}' --json

Provider shortcut

kosmo integrations:youtube youtube_search_videos '{"query":"example_query","type":"example_type","max_results":1,"page_token":"example_page_token","order":"example_order","published_after":"example_published_after","published_before":"example_published_before","region_code":"example_region_code"}' --json

youtube.youtube_get_video_details

Read read

Get detailed information about one or more YouTube videos by ID, including title, description, thumbnails, duration, view count, likes, and channel info.

Parameters
video_ids, part

Generic CLI call

kosmo integrations:call youtube.youtube_get_video_details '{"video_ids":"example_video_ids","part":"example_part"}' --json

Provider shortcut

kosmo integrations:youtube youtube_get_video_details '{"video_ids":"example_video_ids","part":"example_part"}' --json

youtube.youtube_list_channels

Read read

List YouTube channels by username, channel ID, or category. Returns channel snippets, statistics, and content details.

Parameters
for_username, channel_ids, category_id, mine, max_results, page_token, hl

Generic CLI call

kosmo integrations:call youtube.youtube_list_channels '{"for_username":"example_for_username","channel_ids":"example_channel_ids","category_id":"example_category_id","mine":true,"max_results":1,"page_token":"example_page_token","hl":"example_hl"}' --json

Provider shortcut

kosmo integrations:youtube youtube_list_channels '{"for_username":"example_for_username","channel_ids":"example_channel_ids","category_id":"example_category_id","mine":true,"max_results":1,"page_token":"example_page_token","hl":"example_hl"}' --json

youtube.youtube_get_channel

Read read

Get detailed information about a specific YouTube channel by ID, including snippet, statistics (subscribers, views, videos), content details, and branding settings.

Parameters
channel_id, part

Generic CLI call

kosmo integrations:call youtube.youtube_get_channel '{"channel_id":"example_channel_id","part":"example_part"}' --json

Provider shortcut

kosmo integrations:youtube youtube_get_channel '{"channel_id":"example_channel_id","part":"example_part"}' --json

youtube.youtube_list_playlists

Read read

List playlists for a YouTube channel or by playlist IDs. Returns playlist snippets and content details.

Parameters
channel_id, playlist_ids, mine, max_results, page_token

Generic CLI call

kosmo integrations:call youtube.youtube_list_playlists '{"channel_id":"example_channel_id","playlist_ids":"example_playlist_ids","mine":true,"max_results":1,"page_token":"example_page_token"}' --json

Provider shortcut

kosmo integrations:youtube youtube_list_playlists '{"channel_id":"example_channel_id","playlist_ids":"example_playlist_ids","mine":true,"max_results":1,"page_token":"example_page_token"}' --json

youtube.youtube_get_playlist

Read read

Get details about a specific YouTube playlist by ID, including its metadata and up to 50 playlist items (videos).

Parameters
playlist_id, max_results, page_token

Generic CLI call

kosmo integrations:call youtube.youtube_get_playlist '{"playlist_id":"example_playlist_id","max_results":1,"page_token":"example_page_token"}' --json

Provider shortcut

kosmo integrations:youtube youtube_get_playlist '{"playlist_id":"example_playlist_id","max_results":1,"page_token":"example_page_token"}' --json

youtube.youtube_get_current_user

Read read

Get the authenticated user's YouTube channel information, including channel title, description, subscriber count, total views, and video count.

Parameters
none

Generic CLI call

kosmo integrations:call youtube.youtube_get_current_user '{}' --json

Provider shortcut

kosmo integrations:youtube youtube_get_current_user '{}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

youtube.youtube_search_videos

Search for videos, channels, or playlists on YouTube using keywords, filters, and sorting options. Returns matching results with snippet metadata.

Operation
Read read
Schema command
kosmo integrations:schema youtube.youtube_search_videos --json
ParameterTypeRequiredDescription
query string yes Search query text.
type string no Resource type to search for: video, channel, or playlist. Default: video.
max_results integer no Maximum number of results per page (1-50). Default: 10.
page_token string no Token for the next page of results.
order string no Sort order: date, rating, relevance, title, videoCount, viewCount. Default: relevance.
published_after string no RFC 3339 formatted date-time (e.g., "2024-01-01T00:00:00Z"). Only resources created after this date.
published_before string no RFC 3339 formatted date-time. Only resources created before this date.
region_code string no ISO 3166-1 alpha-2 country code (e.g., "US").
channel_id string no Limit search to a specific channel.
video_duration string no Video duration filter: any, long (>20min), medium (4-20min), short (<4min).
safe_search string no Safe search level: moderate, none, strict. Default: moderate.

youtube.youtube_get_video_details

Get detailed information about one or more YouTube videos by ID, including title, description, thumbnails, duration, view count, likes, and channel info.

Operation
Read read
Schema command
kosmo integrations:schema youtube.youtube_get_video_details --json
ParameterTypeRequiredDescription
video_ids string yes Comma-separated YouTube video IDs (e.g., "dQw4w9WgXcQ") or a single video ID. Max 50 IDs.
part string no Comma-separated resource parts to include. Default: snippet,contentDetails,statistics. Options: snippet, contentDetails, statistics, status, topicDetails, recordingDetails, fileDetails, processingDetails, suggestions, liveStreamingDetails, localizations.

youtube.youtube_list_channels

List YouTube channels by username, channel ID, or category. Returns channel snippets, statistics, and content details.

Operation
Read read
Schema command
kosmo integrations:schema youtube.youtube_list_channels --json
ParameterTypeRequiredDescription
for_username string no YouTube username to look up channels for.
channel_ids string no Comma-separated channel IDs (max 50).
category_id string no Guide category ID to filter channels.
mine boolean no Set to true to list the authenticated user's channel.
max_results integer no Maximum results per page (1-50). Default: 5.
page_token string no Token for the next page of results.
hl string no Language code for localized text (e.g., "en", "es").

youtube.youtube_get_channel

Get detailed information about a specific YouTube channel by ID, including snippet, statistics (subscribers, views, videos), content details, and branding settings.

Operation
Read read
Schema command
kosmo integrations:schema youtube.youtube_get_channel --json
ParameterTypeRequiredDescription
channel_id string yes The YouTube channel ID (e.g., "UC_x5XG1OV2P6uZZ5FSM9Ttw").
part string no Comma-separated resource parts. Default: snippet,contentDetails,statistics,brandingSettings.

youtube.youtube_list_playlists

List playlists for a YouTube channel or by playlist IDs. Returns playlist snippets and content details.

Operation
Read read
Schema command
kosmo integrations:schema youtube.youtube_list_playlists --json
ParameterTypeRequiredDescription
channel_id string no YouTube channel ID to list playlists for.
playlist_ids string no Comma-separated playlist IDs to look up (max 50).
mine boolean no Set to true to list the authenticated user's playlists.
max_results integer no Maximum results per page (1-50). Default: 5.
page_token string no Token for the next page of results.

youtube.youtube_get_playlist

Get details about a specific YouTube playlist by ID, including its metadata and up to 50 playlist items (videos).

Operation
Read read
Schema command
kosmo integrations:schema youtube.youtube_get_playlist --json
ParameterTypeRequiredDescription
playlist_id string yes The YouTube playlist ID (e.g., "PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf").
max_results integer no Maximum playlist items to return (1-50). Default: 10.
page_token string no Token for the next page of playlist items.

youtube.youtube_get_current_user

Get the authenticated user's YouTube channel information, including channel title, description, subscriber count, total views, and video count.

Operation
Read read
Schema command
kosmo integrations:schema youtube.youtube_get_current_user --json
ParameterTypeRequiredDescription
No parameters.

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.