Base URL: https://www.googleapis.com/youtube/v3
---
1. Search Videos
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/search?part=snippet&q=kubernetes+tutorial&type=video&maxResults=5&key=${YOUTUBE_API_KEY}"' | jq '.items[] | {videoId: .id.videoId, title: .snippet.title, channel: .snippet.channelTitle}'
```
---
2. Search with Filters
Search for videos uploaded this year, ordered by view count:
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/search?part=snippet&q=react+hooks&type=video&order=viewCount&publishedAfter=2024-01-01T00:00:00Z&maxResults=10&key=${YOUTUBE_API_KEY}"' | jq '.items[] | {videoId: .id.videoId, title: .snippet.title}'
```
---
3. Get Video Details
Replace with an actual video ID:
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics,contentDetails&id=&key=${YOUTUBE_API_KEY}"' | jq '.items[0] | {title: .snippet.title, views: .statistics.viewCount, likes: .statistics.likeCount, duration: .contentDetails.duration}'
```
---
4. Get Multiple Videos
Replace , , with actual video IDs:
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics&id=,,&key=${YOUTUBE_API_KEY}"' | jq '.items[] | {id: .id, title: .snippet.title, views: .statistics.viewCount}'
```
---
5. Get Trending Videos
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics&chart=mostPopular®ionCode=US&maxResults=10&key=${YOUTUBE_API_KEY}"' | jq '.items[] | {title: .snippet.title, channel: .snippet.channelTitle, views: .statistics.viewCount}'
```
---
6. Get Channel by ID
Replace with an actual channel ID:
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&id=&key=${YOUTUBE_API_KEY}"' | jq '.items[0] | {title: .snippet.title, subscribers: .statistics.subscriberCount, videos: .statistics.videoCount}'
```
---
7. Get Channel by Handle
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&forHandle=@GoogleDevelopers&key=${YOUTUBE_API_KEY}"' | jq '.items[0] | {id: .id, title: .snippet.title, subscribers: .statistics.subscriberCount}'
```
---
8. Get Channel by Username
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&forUsername=GoogleDevelopers&key=${YOUTUBE_API_KEY}"' | jq '.items[0] | {id: .id, title: .snippet.title, description: .snippet.description}'
```
---
9. List Playlist Items
Replace with an actual playlist ID:
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=&maxResults=20&key=${YOUTUBE_API_KEY}"' | jq '.items[] | {position: .snippet.position, title: .snippet.title, videoId: .snippet.resourceId.videoId}'
```
---
10. Get Channel Uploads Playlist
First get the channel's uploads playlist ID, then list videos. Replace with an actual channel ID:
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=&key=${YOUTUBE_API_KEY}"' | jq -r '.items[0].contentDetails.relatedPlaylists.uploads'
```
---
11. Get Video Comments
Replace with an actual video ID:
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&videoId=&maxResults=20&order=relevance&key=${YOUTUBE_API_KEY}"' | jq '.items[] | {author: .snippet.topLevelComment.snippet.authorDisplayName, text: .snippet.topLevelComment.snippet.textDisplay, likes: .snippet.topLevelComment.snippet.likeCount}'
```
---
12. Search Comments
Replace with an actual video ID:
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&videoId=&searchTerms=great+video&maxResults=10&key=${YOUTUBE_API_KEY}"' | jq '.items[] | {author: .snippet.topLevelComment.snippet.authorDisplayName, text: .snippet.topLevelComment.snippet.textDisplay}'
```
---
13. Get Video Categories
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/videoCategories?part=snippet®ionCode=US&key=${YOUTUBE_API_KEY}"' | jq '.items[] | {id: .id, title: .snippet.title}'
```
---
14. Search Videos by Category
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&videoCategoryId=28&maxResults=10&key=${YOUTUBE_API_KEY}"' | jq '.items[] | {videoId: .id.videoId, title: .snippet.title}'
```
Note: Category 28 = Science & Technology
---
15. Get Playlists from Channel
Replace with an actual channel ID:
```bash
bash -c 'curl -s "https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=&maxResults=20&key=${YOUTUBE_API_KEY}"' | jq '.items[] | {id: .id, title: .snippet.title, description: .snippet.description}'
```
---