Claude
Skills
Sign in
Back

youtube-data-api

Included with Lifetime
$97 forever

YouTube Data API v3 complete wrapper - search videos, get video/channel/playlist details, get comments, download subtitles, etc. Supports filtering and sorting by time/views/rating and more.

Image & Videoscripts

What this skill does


# YouTube Data API v3 Skill

Complete wrapper based on official YouTube Data API v3 documentation.

## Configuration

### API Key Setup

```bash
# Option 1: Environment variable (recommended)
export YOUTUBE_API_KEY="YOUR_API_KEY_HERE"

# Option 2: Edit config file directly
# Edit ~/.claude/skills/youtube-data-api/scripts/config.py
```

### Getting an API Key

1. Go to [Google Cloud Console](https://console.cloud.google.com/)
2. Create a new project or select existing
3. Enable YouTube Data API v3
4. Create credentials → API Key
5. (Optional) Restrict API Key to YouTube Data API only

### Quota Limits

| Operation Type | Quota Cost (units) |
|----------------|-------------------|
| Read operations (list) | 1 |
| Search requests | 100 |
| Write operations (insert/update/delete) | 50 |
| Video upload | 1600 |

**Default daily quota**: 10,000 units

---

## Core Features

### 1. Search Videos (Search)

**Quota cost**: 100 units/request

```bash
# Basic search
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py search \
    --query "Python tutorial" \
    --max-results 25

# Filter by time (last week)
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py search \
    --query "machine learning" \
    --published-after "7d" \
    --type video

# Sort by view count
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py search \
    --query "React hooks" \
    --order viewCount \
    --type video

# HD videos only
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py search \
    --query "4K nature" \
    --video-definition high \
    --type video

# Videos with captions
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py search \
    --query "TED talk" \
    --video-caption closedCaption \
    --type video

# Live streaming videos
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py search \
    --query "gaming" \
    --event-type live \
    --type video

# Filter by region
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py search \
    --query "news" \
    --region-code US \
    --relevance-language en

# Filter by video duration
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py search \
    --query "documentary" \
    --video-duration long \
    --type video
```

#### Search Parameters Reference

| Parameter | Description | Values |
|-----------|-------------|--------|
| `--query, -q` | Search keywords | Supports boolean operators (`python AND tutorial`) |
| `--type` | Resource type | `video`, `channel`, `playlist` |
| `--max-results` | Results count | 1-50, default 25 |
| `--order` | Sort order | `relevance`(default), `date`, `rating`, `viewCount`, `title` |
| `--published-after` | Published after | `1d`, `7d`, `30d`, `1y` or ISO 8601 format |
| `--published-before` | Published before | Same as above |
| `--region-code` | Region code | ISO 3166-1 (e.g., `US`, `CN`, `JP`) |
| `--relevance-language` | Language | ISO 639-1 (e.g., `en`, `zh`, `ja`) |
| `--video-duration` | Video length | `short`(<4min), `medium`(4-20min), `long`(>20min) |
| `--video-definition` | Definition | `high`(HD), `standard`(SD) |
| `--video-caption` | Captions | `closedCaption`(has captions), `none`(no captions) |
| `--video-dimension` | Dimension | `2d`, `3d` |
| `--event-type` | Live status | `live`(streaming), `completed`(ended), `upcoming`(scheduled) |
| `--channel-id` | Limit to channel | Channel ID |
| `--safe-search` | Safe search | `none`, `moderate`, `strict` |

---

### 2. Get Video Details (Videos)

**Quota cost**: 1 unit/request

```bash
# Get single video details
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py video \
    --id "dQw4w9WgXcQ" \
    --parts snippet,statistics,contentDetails

# Get multiple videos (batch)
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py video \
    --id "dQw4w9WgXcQ,jNQXAC9IVRw,9bZkp7q19f0" \
    --parts snippet,statistics

# Get trending videos
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py video \
    --chart mostPopular \
    --region-code US \
    --max-results 50

# Get trending by category
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py video \
    --chart mostPopular \
    --video-category-id 10 \
    --region-code JP
```

#### Video Parts Reference

| Part | Contains |
|------|----------|
| `snippet` | Title, description, thumbnails, channel info, publish time, tags |
| `statistics` | View count, like count, comment count |
| `contentDetails` | Duration, definition, caption info, region restrictions |
| `status` | Upload status, privacy, license |
| `player` | Embedded player HTML |
| `topicDetails` | Related topic IDs |
| `recordingDetails` | Recording location, date |
| `liveStreamingDetails` | Live info (start/end time, viewer count) |

#### Video Category IDs Reference

| ID | Category | ID | Category |
|----|----------|----|----|
| 1 | Film & Animation | 20 | Gaming |
| 2 | Autos & Vehicles | 22 | People & Blogs |
| 10 | Music | 23 | Comedy |
| 15 | Pets & Animals | 24 | Entertainment |
| 17 | Sports | 25 | News & Politics |
| 19 | Travel & Events | 26 | Howto & Style |
| 27 | Education | 28 | Science & Technology |

---

### 3. Get Channel Info (Channels)

**Quota cost**: 1 unit/request

```bash
# Get by channel ID
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py channel \
    --id "UC_x5XG1OV2P6uZZ5FSM9Ttw" \
    --parts snippet,statistics,contentDetails

# Get by username
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py channel \
    --for-username "GoogleDevelopers" \
    --parts snippet,statistics

# Get by handle (@username)
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py channel \
    --for-handle "@Google" \
    --parts snippet,statistics,brandingSettings
```

#### Channel Parts Reference

| Part | Contains |
|------|----------|
| `snippet` | Channel name, description, thumbnails, country |
| `statistics` | Subscriber count, video count, total views |
| `contentDetails` | Related playlists (uploads, likes, etc.) |
| `brandingSettings` | Channel banner, keywords, default language |
| `topicDetails` | Channel topics |
| `status` | Channel status (long video upload permission, etc.) |

---

### 4. Get Playlists (Playlists)

**Quota cost**: 1 unit/request

```bash
# Get playlist by ID
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py playlist \
    --id "PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf" \
    --parts snippet,contentDetails

# Get all playlists for a channel
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py playlist \
    --channel-id "UC_x5XG1OV2P6uZZ5FSM9Ttw" \
    --max-results 50
```

---

### 5. Get Playlist Videos (PlaylistItems)

**Quota cost**: 1 unit/request

```bash
# Get all videos in a playlist
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py playlist-items \
    --playlist-id "PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf" \
    --max-results 50

# Paginated retrieval
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py playlist-items \
    --playlist-id "PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf" \
    --page-token "NEXT_PAGE_TOKEN"
```

---

### 6. Get Comments (Comments & CommentThreads)

**Quota cost**: 1 unit/request

```bash
# Get all comments for a video (top-level)
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py comments \
    --video-id "dQw4w9WgXcQ" \
    --max-results 100 \
    --order relevance

# Get comments for a channel
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py comments \
    --channel-id "UC_x5XG1OV2P6uZZ5FSM9Ttw" \
    --max-results 50

# Get replies to a comment
python ~/.claude/skills/youtube-data-api/scripts/youtube_api.py comment-replies \
    --parent-id "COMMENT_ID" \
    --max-results 50
```

#### Comment Sort Options

| Sort | Description |
|------|-------------|
| `relevance` | By relevance (default) |
| `time` | By time (newest first) |

---

### 7. Get Captions (Captions)

**Quota cost**: 1 unit/request (list)

Related in Image & Video