> ## Documentation Index
> Fetch the complete documentation index at: https://slatehq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# YouTube Block

> Search for videos and retrieve video details including transcripts from YouTube.

## Overview

The YouTube block retrieves video data from YouTube. Use it to search for videos by keyword, get video details, or extract transcripts for content research, competitor analysis, and video content creation.

***

## Configuration

### Operation

Select the YouTube operation to perform.

| Operation | Description |
| - | - |
| **Search Videos** | Search YouTube for videos by keyword |
| **Get Video Details** | Retrieve detailed information about a specific video |

***

## Search Videos Configuration

Use these settings when the operation is set to "Search Videos".

### Search Query

Enter the keyword or phrase to search for on YouTube. This field supports placeholders for dynamic values.

**Examples:**

* Static search: `SEO tutorial 2024`
* From previous step: `{{step_1.output.topic}}`
* Combined: `{{input.keyword}} tutorial`

***

### Max Results

Set the maximum number of videos to retrieve.

* **Default**: 10 videos
* **Recommended**: Start with 10, increase as needed

***

### Sorting Order

Choose how search results are sorted.

| Sort Option | Description |
| - | - |
| **Relevance** | Most relevant to your search term (default) |
| **Date** | Most recently uploaded |
| **Views** | Most viewed videos |
| **Rating** | Highest rated videos |

***

## Search Videos Output

The Search Videos operation returns an array of video objects.

### Output Structure

```json theme={null}
[
  {
    "title": "Complete SEO Tutorial for Beginners",
    "url": "https://www.youtube.com/watch?v=abc123",
    "thumbnailUrl": "https://i.ytimg.com/vi/abc123/maxresdefault.jpg",
    "viewCount": 1250000,
    "date": "2024-01-15",
    "likes": 45000,
    "channelName": "SEO Expert",
    "channelUrl": "https://www.youtube.com/channel/...",
    "channelUsername": "@seoexpert",
    "duration": "25:30",
    "commentsCount": 1200,
    "text": "In this tutorial, I'll show you everything you need to know about SEO...",
    "hashtags": ["#SEO", "#Tutorial", "#Marketing"]
  }
]
```

### Search Videos Output Fields

| Field | Description |
| - | - |
| `title` | Video title |
| `url` | Direct URL to the video |
| `thumbnailUrl` | Video thumbnail image URL |
| `viewCount` | Number of views |
| `date` | Upload date |
| `likes` | Number of likes |
| `channelName` | Name of the YouTube channel |
| `channelUrl` | URL to the channel |
| `channelUsername` | Channel username/handle |
| `duration` | Video length (e.g., "25:30") |
| `commentsCount` | Number of comments |
| `text` | Video description |
| `hashtags` | Array of hashtags used |

### Accessing Search Results

**Get first video:**

```
{{step_n.output[0]}}
```

**Get first video title:**

```
{{step_n.output[0].title}}
```

**Get first video URL (to use with Get Video Details):**

```
{{step_n.output[0].url}}
```

**Loop through all videos:**

```liquid theme={null}
{% for video in step_n.output %}
  Title: {{ video.title }}
  Views: {{ video.viewCount }}
  Channel: {{ video.channelName }}
{% endfor %}
```

***

## Get Video Details Configuration

Use these settings when the operation is set to "Get Video Details".

### Video URL

Enter the full YouTube video URL. This field supports placeholders for dynamic values.

**Examples:**

* Direct URL: `https://www.youtube.com/watch?v=abc123`
* From previous step: `{{step_1.output[0].url}}`
* From loop: `{{current.url}}`

***

### Get Transcript

Enable this option to download the video's subtitles/transcript.

* **Enabled**: Includes transcript in SRT format
* **Disabled**: Returns video details without transcript (default)

> [!TIP]
>
> Transcripts are useful for content repurposing, SEO analysis, and extracting key points from videos.

***

## Get Video Details Output

The Get Video Details operation returns a single video object with detailed information.

### Output Structure

```json theme={null}
{
  "title": "Complete SEO Tutorial for Beginners",
  "thumbnailUrl": "https://i.ytimg.com/vi/abc123/maxresdefault.jpg",
  "viewCount": 1250000,
  "date": "2024-01-15",
  "likes": 45000,
  "channelName": "SEO Expert",
  "channelUrl": "https://www.youtube.com/channel/...",
  "numberOfSubscribers": 500000,
  "duration": "25:30",
  "commentsCount": 1200,
  "text": "In this tutorial, I'll show you everything you need to know about SEO...",
  "subtitles": "1\n00:00:00,000 --> 00:00:05,000\nWelcome to this SEO tutorial...\n\n2\n00:00:05,000 --> 00:00:10,000\nToday we'll cover..."
}
```

### Get Video Details Output Fields

| Field | Description |
| - | - |
| `title` | Video title |
| `thumbnailUrl` | Video thumbnail image URL |
| `viewCount` | Number of views |
| `date` | Upload date |
| `likes` | Number of likes |
| `channelName` | Name of the YouTube channel |
| `channelUrl` | URL to the channel |
| `numberOfSubscribers` | Channel subscriber count |
| `duration` | Video length |
| `commentsCount` | Number of comments |
| `text` | Video description |
| `subtitles` | Transcript in SRT format (if requested) |

### Accessing Video Details

**Get video title:**

```
{{step_n.output.title}}
```

**Get transcript:**

```
{{step_n.output.subtitles}}
```

**Get channel info:**

```
Channel: {{step_n.output.channelName}} ({{step_n.output.numberOfSubscribers}} subscribers)
```

***

## Credits

| Operation | Credits |
| - | - |
| **Search Videos** | 20 credits per 10 results |
| **Get Video Details** | 5 credits per video |

**Examples:**

* Search returning 10 videos = 20 credits
* Search returning 15 videos = 40 credits
* Get details for 1 video = 5 credits

***

## Best Practices

### Search Videos

* Use specific keywords for more relevant results
* Include year or "2024" for recent content
* Start with 10 results, increase if needed
* Use "Views" sort to find popular content
* Use "Date" sort for trending topics

### Get Video Details

* Enable transcript for content repurposing
* Combine with LLM to summarize long videos
* Extract key timestamps from transcripts
* Use subscriber count to assess channel authority

***

## Common Use Cases

| Use Case | Operation | Configuration Tips |
| - | - | - |
| Topic research | Search Videos | Search your keyword, sort by Views |
| Competitor analysis | Search Videos | Search competitor brand name |
| Content repurposing | Get Video Details | Enable transcript, analyze with LLM |
| Trending content | Search Videos | Sort by Date for recent uploads |
| Influencer research | Search Videos | Analyze channel subscriber counts |
| Video script creation | Get Video Details | Extract transcript, rewrite with LLM |

***

## Example Workflow: Video Research

Research video content on a topic:

1. **YouTube Block** (Search Videos):
   * Operation: Search Videos
   * Search Query: `{{input.topic}} tutorial`
   * Max Results: 10
   * Sorting Order: Views

2. **LLM Block**:
   ```
   Analyze these top YouTube videos about "{{input.topic}}":

   1. What topics do the most popular videos cover?
   2. What are common video lengths?
   3. What patterns do you see in titles?
   4. What content gaps exist?

   Videos:
   {{step_1.output}}
   ```

3. **Google Sheets Block**: Store research findings

***

## Example Workflow: Transcript Analysis

Extract and analyze video transcripts:

1. **YouTube Block** (Search Videos):
   * Operation: Search Videos
   * Search Query: `{{input.keyword}}`
   * Max Results: 5
   * Sorting Order: Views

2. **Loop Block**: Process each video

3. **YouTube Block** (Get Video Details):
   * Operation: Get Video Details
   * Video URL: `{{current.url}}`
   * Get Transcript: Enabled

4. **LLM Block**:
   ```
   Summarize this video transcript:
   - Main topics covered
   - Key takeaways (5 bullet points)
   - Actionable tips mentioned

   Transcript:
   {{step_3.output.subtitles}}
   ```

5. **Google Sheets Block**: Append summaries

***

## Example Workflow: Competitor Video Analysis

Analyze competitor YouTube content:

1. **Google Sheets Block**: Read list of competitor channel names

2. **Loop Block**: Process each competitor

3. **YouTube Block** (Search Videos):
   * Operation: Search Videos
   * Search Query: `{{current.channel_name}}`
   * Max Results: 10
   * Sorting Order: Views

4. **LLM Block**:
   ```
   Analyze {{current.channel_name}}'s top YouTube videos:
   - Content themes
   - Average engagement (views, likes)
   - Video format patterns
   - Opportunities to differentiate

   {{step_3.output}}
   ```

5. **Google Sheets Block**: Append competitor analysis

***

## Troubleshooting

### Search Videos Issues

| Issue | Cause | Solution |
| - | - | - |
| No videos found | Search term too specific | Try broader keywords |
| Irrelevant results | Generic search term | Add more specific keywords |
| Old videos only | Default sorting | Use "Date" sort for recent content |

### Get Video Details Issues

| Issue | Cause | Solution |
| - | - | - |
| Video not found | Invalid URL | Verify the YouTube URL is correct |
| No transcript | Subtitles unavailable | Not all videos have transcripts |
| Empty transcript | Auto-captions disabled | Video owner hasn't enabled captions |
| Slow response | Transcript processing | Transcripts take longer to fetch |

***

## What's Next

Now that you understand the YouTube block:

* Learn about [LLM Block](https://slatehq.com/docs/workflows/blocks/ai/llm.md) to analyze video content
* See [Loop Block](https://slatehq.com/docs/workflows/blocks/flow/loop.md) to process multiple videos
* Explore [Google Sheets Block](https://slatehq.com/docs/workflows/blocks/apps/google-sheets.md) to store video data
* Check [Reddit Block](https://slatehq.com/docs/workflows/blocks/data-sources/reddit.md) for additional content research


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.