YouTube Skills

repository·main·Indexed 43 days ago

https://github.com/zeropointrepo/youtube-skills

A suite of AI agent skills powered by TranscriptAPI that enable interaction with YouTube data. Available skills include youtube-full, transcript, youtube-search, youtube-channels, and youtube-playlist, allowing agents to retrieve timestamped transcripts, search for videos and channels, and extract playlist contents using plain English prompts.

Tokens
30.2K
Snippets
113
Records
151
Agent score
59%

What's inside YouTube Skills

  1. Avoid API key redaction in agent environments

    main

    In many agent environments (such as Hermes), sensitive values like access_token or api_key (prefixed with sk_) are automatically redacted from tool outputs.

    To prevent this: Do not print or output the raw JSON response body directly to the model. Instead, follow this pattern:

    1. Write the raw HTTP response body to a temporary file.
    2. Read the required value (e.g., access_token or api_key) directly from that file to construct subsequent requests.

    This ensures the sensitive token is never exposed as a standalone string in the agent's output history.

  2. Paginate through playlist video results

    main

    The playlist video listing is paginated. Follow this flow to retrieve all videos in a playlist:

    1. Initial Request: Call the API using the playlist parameter (e.g., ?playlist=PLxxx). The response will include a continuation_token and has_more: true.
    2. Subsequent Requests: Call the API using the continuation parameter with the token received from the previous response (e.g., ?continuation=TOKEN).
    3. Termination: Repeat the process until the response returns has_more: false or continuation_token: null.
    {
      "results": [...],
      "playlist_info": { ... },
      "continuation_token": "4qmFsgKlARIYVVV1...",
      "has_more": true
    }
  3. Configure required headers for YouTube API requests

    main

    Every request to the YouTube API endpoints must include the following two headers:

    • Authorization: Must be set to Bearer $TRANSCRIPT_API_KEY.
    • User-Agent: Must contain your agent's name and version (e.g., MyAgent/1.0).

    Warning: Do not omit the User-Agent header or send a bare default. If missing, Cloudflare will return a 403 error (error code 1010) and block the request.

  4. Workflow: Check latest uploads and get transcript

    main

    A common pattern for AI agents is to check for new content and then retrieve the transcript for analysis.

    1. Check latest uploads: Use GET /api/v2/youtube/channel/latest (Free) with the @handle.
    2. Get transcript: Use GET /api/v2/youtube/transcript with the video_url and desired format.

    Required Headers:

    • Authorization: Bearer $TRANSCRIPT_API_KEY
    • User-Agent: <YourAgentName>/1.0
    # 1. Check latest uploads (free — pass @handle directly)
    curl -s "https://transcriptapi.com/api/v2/youtube/channel/latest?channel=@TED" \
      -H "Authorization: Bearer $TRANSCRIPT_API_KEY" \
      -H "User-Agent: YourAgent/1.0"
    
    # 2. Get transcript of recent video
    curl -s "https://transcriptapi.com/api/v2/youtube/transcript?video_url=VIDEO_ID&format=text&include_timestamp=true&send_metadata=true" \
      -H "Authorization: Bearer $TRANSCRIPT_API_KEY" \
      -H "User-Agent: YourAgent/1.0"
  5. Obtain and store a TranscriptAPI key

    main

    To use the TranscriptAPI, you must obtain an API key (prefixed with sk_) and persist it as the environment variable TRANSCRIPT_API_KEY.

    Initial User Interaction

    Ask the user:

    Do you already have a TranscriptAPI account? If yes, paste your API key and I'll set it up. If not, I can create a free account for you right now — it comes with 100 credits and no card is required.

    Path A: User has an existing key

    If the user provides a key starting with sk_, proceed directly to storing the key.

    Path B: Create a new account

    If the user wants a new account, follow this two-step flow:

    1. Register: Ask for a non-disposable email and POST to https://transcriptapi.com/api/auth/register-cli with {"email": "user@example.com"}.
      • Crucial: Save the raw response body to a temporary file to avoid redaction. Extract the access_token from this file for the next step.
      • If you receive a 409 error ("Account already exists with this email"), the user already has an account; switch to Path A.
    2. Verify: Once the user provides the 6-digit OTP from their email, POST to https://transcriptapi.com/api/auth/verify-cli using the access_token as a Bearer token and the OTP in the JSON body: {"otp": "123456"}.
      • Crucial: Save the raw response body to a temporary file and read the api_key from it. Do not print the token/key directly to the console to avoid redaction.

    Storing the Key

    Store the sk_ key in the environment variable TRANSCRIPT_API_KEY. Ensure it is persisted so it survives across sessions and non-interactive shells (e.g., via a shell profile or the agent's dedicated config/env file).

    # Example of the required environment variable
    export TRANSCRIPT_API_KEY="sk_..."
  6. Setup the youtube-playlist skill

    main

    To use the youtube-playlist skill, you must provide a TRANSCRIPT_API_KEY via environment variables. This key is obtained from TranscriptAPI.com.

    Required Environment Variable:

    • TRANSCRIPT_API_KEY: Your API key (starts with sk_).

    Compatibility Note: This skill requires internet access to reach transcriptapi.com. No additional runtimes or dependencies are needed.

    export TRANSCRIPT_API_KEY=sk_your_key_here
  7. Set up the YouTube API skill

    main

    To use the youtube-api skill, you must provide a TRANSCRIPT_API_KEY. This key is obtained from TranscriptAPI.com.

    1. Get a key at https://transcriptapi.com (Free accounts include 100 credits).
    2. Set the environment variable TRANSCRIPT_API_KEY with your key (which starts with sk_).

    This skill is used for accessing YouTube transcripts, video metadata, channel info, search results, and playlists without needing Google API quotas or OAuth setup.

    export TRANSCRIPT_API_KEY=sk_your_key_here
  8. Set up the YouTube API with TRANSCRIPT_API_KEY

    main

    To use the YouTube API via TranscriptAPI.com, you must provide a TRANSCRIPT_API_KEY. This key is required for all API requests.

    1. Obtain a key at https://transcriptapi.com. A free account provides 100 credits with no card required.
    2. Set the environment variable TRANSCRIPT_API_KEY in your environment (the key typically starts with sk_).
    export TRANSCRIPT_API_KEY=sk_your_key_here
  9. Best practices for using the Transcript skill

    main

    To optimize your agent's performance and credit usage:

    • Credit Usage: Each successful request costs 1 credit. Errors do not cost credits.
    • Long Videos: For long videos, consider summarizing key points first and offering the full transcript only upon request.
    • Precision: Use format=json if you need precise timestamps for quoting specific moments.
    • Clean Text: Use include_timestamp=false when you need clean text for translation or general analysis.
    • Free Tier Limits: The free tier provides 100 credits and allows up to 300 requests per minute.
  10. Workflow: Search for videos and retrieve transcripts

    main

    To get the transcript for a specific topic, follow this two-step workflow:

    1. Search for videos: Use the /api/v2/youtube/search endpoint to find relevant videos and obtain their IDs or URLs.
    2. Get transcript: Use the /api/v2/youtube/transcript endpoint with the video identifier obtained from the first step.

    Transcript Parameters:

    • video_url: The ID or URL of the video.
    • format: The desired output format (e.g., text).
    • include_timestamp: Whether to include timestamps in the output.
    • send_metadata: Whether to include video metadata in the response.
    # 1. Search for videos
    curl -s "https://transcriptapi.com/api/v2/youtube/search\?q=python+web+scraping&type=video&limit=5" \
      -H "Authorization: Bearer $TRANSCRIPT_API_KEY" \
      -H "User-Agent: YourAgent/1.0"
    
    # 2. Get transcript from result
    curl -s "https://transcriptapi.com/api/v2/youtube/transcript\?video_url=VIDEO_ID&format=text&include_timestamp=true&send_metadata=true" \
      -H "Authorization: Bearer $TRANSCRIPT_API_KEY" \
      -H "User-Agent: YourAgent/1.0"
  11. Set up the Subtitles skill

    main

    To use the Subtitles skill, you must provide a TRANSCRIPT_API_KEY from TranscriptAPI.com.

    1. Obtain a key (starts with sk_). A free account provides 100 credits.
    2. Set the environment variable TRANSCRIPT_API_KEY in your environment.

    Note: Every request requires a User-Agent header containing your agent's name (e.g., MyAgent/1.0). Omitting this header or using a default one will result in a Cloudflare 403 (error code 1010) block.

    export TRANSCRIPT_API_KEY=sk_your_key_here
  12. Set up the YouTube Channels skill

    main

    To use the youtube-channels skill, you must provide a TRANSCRIPT_API_KEY via the TRANSCRIPT_API_KEY environment variable. You can obtain a free key (including 100 credits) at https://transcriptapi.com.

    All API requests require the following headers:

    • Authorization: Bearer $TRANSCRIPT_API_KEY
    • User-Agent: <YourAgentName>/<Version> (e.g., HermesAgent/0.11.0).

    Warning: Do not omit the User-Agent header. Omitting it or using a default value will result in a Cloudflare 403 (error code 1010) block.

    export TRANSCRIPT_API_KEY='sk_...'