With YouTube API v3, it has became quite tough to fetch YouTube data like comments, replies, perform search, get search results like videos, channels, playlist or any regional videos. Here in this article I have written the Python script that can fetch the above mentioned public data using API key. This script is purely based on API key without any requirement of Oauth.

To use this script you need to get the API key from the Google API console. Below is the official video to obtain the API key from the Google API console. The script is available on GitHub. Feedback and contribution is welcomed.

 

 

Requirements

Python 3.x is required to tun this script.

An API key

 

How to use

(– stands for – – (Double dash))

Pass –c after file name for calling Video Comment function Pass –s after file name for calling Search by Keyword Pass –sc after file name for calling Search videos by YouTube ChannelId. It is mandatory to pass any of the above argument after file name

 

Video Comments
  • python youtube_api_cmd.py –max –videourl –key
  • –max parameter for defining the maximum result you want (maxlimit = 100, default=20)
  • –videourl parameter for defining the youtube URL
  • –key parameter for defining your developer API key
  • –videourl and –key parameter is mandatory. –max parameter is optional

 

Search by Keyword
  • python youtube_api_cmd.py –search –max –key
  • –max parameter for defining the maximum result you want (maxlimit = 100, default=20)
  • –search parameter for giving the keyword
  • –r parameter for defining region (Country) For ex. –r=IN (Parameter should be a country code)
  • –key parameter for defining your developer API key Mandatory
  • It will return Videos, Channel and Playlist in the respective category

 

Search Videos by YouTube ChannelId
  • python youtube_api_cmd.py –channelid –max –key
  • –max parameter for defining the maximum result you want (maxlimit = 100, default=20)
  • –channelid parameter for defining channel id Mandatory
  • –key parameter for defining your developer API key Mandatory
  • It will list of Videos from the defined YouTube ChannelId

 

YouTube API v3

 

Keep sharing. Stay tuned to Tech Tunes.

 

Follow me on Twitter