from youtubesearchpython import VideosSearch
search = VideosSearch('Watermelon Sugar', limit=1)
print(search.result()){
"result": [
{
"type": "video",
"id": "E07s5ZYygMg",
"title": "Harry Styles - Watermelon Sugar (Official Video)",
"publishedTime": "6 months ago",
"duration": "3:09",
"viewCount": {
"text": "162,235,006 views",
"short": "162M views"
},
"thumbnails": [...],
"descriptionSnippet": [...],
"channel": {
"name": "Harry Styles",
"id": "UCZFWPqqPkFlNwIxcpsLOwew",
"thumbnails": [...],
"link": "https://www.youtube.com/channel/..."
},
"link": "https://www.youtube.com/watch?v=E07s5ZYygMg"
}
]
}from youtubesearchpython import ChannelsSearch
search = ChannelsSearch('Harry Styles', limit=1)
print(search.result()){
"result": [
{
"type": "channel",
"id": "UCZFWPqqPkFlNwIxcpsLOwew",
"title": "Harry Styles",
"thumbnails": [...],
"videoCount": "7",
"descriptionSnippet": null,
"subscribers": "9.25M subscribers",
"link": "https://www.youtube.com/channel/..."
}
]
}from youtubesearchpython import PlaylistsSearch
search = PlaylistsSearch('Harry Styles', limit=1)
print(search.result()){
"result": [
{
"type": "playlist",
"id": "PL-Rt4gIwHnyvxpEl-9Le0ePztR7WxGDGV",
"title": "fine line harry styles full album lyrics",
"videoCount": "12",
"channel": {
"name": "ourmemoriestonight",
"id": "UCZCmb5a8LE9LMxW9I3-BFjA",
"link": "https://www.youtube.com/channel/..."
},
"thumbnails": [...],
"link": "https://www.youtube.com/playlist?list=..."
}
]
}from youtubesearchpython import ChannelSearch
# Search within a specific channel
search = ChannelSearch('Watermelon Sugar', "UCZFWPqqPkFlNwIxcpsLOwew")
print(search.result()){
"result": [
{
"id": "WMcIfZuRuU8",
"thumbnails": {...},
"title": "Harry Styles – Watermelon Sugar (Lost Tour Visual)",
"descriptionSnippet": "This video is dedicated to touching...",
"uri": "/watch?v=WMcIfZuRuU8",
"views": {
"precise": "3,888,287 views",
"simple": "3.8M views",
"approximate": "3.8 million views"
},
"duration": {
"simpleText": "2:55",
"text": "2 minutes, 55 seconds"
},
"published": "10 months ago",
"channel": {...},
"type": "video"
}
]
}from youtubesearchpython import CustomSearch, VideoSortOrder
# Search with custom sort order
search = CustomSearch('Harry Styles', VideoSortOrder.viewCount, limit=1)
print(search.result())SearchMode.videos- Only videosSearchMode.channels- Only channelsSearchMode.playlists- Only playlistsSearchMode.livestreams- Only live streams
VideoUploadDateFilter.lastHourVideoUploadDateFilter.todayVideoUploadDateFilter.thisWeekVideoUploadDateFilter.thisMonthVideoUploadDateFilter.thisYear
VideoDurationFilter.short- Under 4 minutesVideoDurationFilter.long- Over 20 minutes
VideoSortOrder.relevance- Most relevant (default)VideoSortOrder.uploadDate- Recently uploadedVideoSortOrder.viewCount- Most viewedVideoSortOrder.rating- Highest rated
from youtubesearchpython import Search
# Searches for videos, channels, and playlists
search = Search('Watermelon Sugar', limit=20)
print(search.result())Returns mixed results containing videos, channels, and playlists.
All search classes support pagination with the next() method:
search = VideosSearch('NoCopyrightSounds', limit=10)
print(search.result())
# Get next page
search.next()
print(search.result())