Youtube search with python

In this article, we shall see how to search youtube with python and get a JSON response with a link to the videos, thumbnails, etc. All these are possible with the help of a python library called youtube-search-python. Let us get started by installing the library.


This package can be installed easily using pip as,

pip install youtube-search-python

You can also clone the repo from here and run the following command on the terminal inside the downloaded or cloned directory.

python install

Once the package is installed we are good to go.


Made without using YouTube Data API v3 and any other third-party library. This library is intended for personal and non-commercial usage only.

We can use this library to search for both music videos and playlists. We can also specify the number of results the search function should return.

Each search result will return the following details.

  1. id
  2. link
  3. title
  4. channel
  6. thumbnails url

Let us look at the example code for each of music video search and also playlist search.

Music video search

The following code snippet shows you how to search for music videos using python. We have to import the SearchVideos class from the youtubesearchpython module.

This will take the name, offset value, response mode and maximum results per search results as the arguments.

music video search

The output of the above code snippet is,

Playlist search

Playlist search is also similar to this one. We import the SearchPlaylists class from youtubesearchpython module. This class also takes the same arguments as the SearchVideos class.

But the response of the SearchPlaylists class is different. The following data are contained in the response of this class.

  1. id
  2. link
  3. index
  4. title
playlist search

The response of the above code snippet is,


This library is pretty much straight-forward and easy to use compared to other libraries. It also returns all the necessary details.

Happy coding!