This repository provides a simple Python script that demonstrates how to use the YouTube API to search for videos based on a query. The script fetches video details such as titles and video IDs from the search results.
- Python 3.x
- Install the
google-api-python-client
library using the following command:
pip install google-api-python-client
-
Clone this repository to your local machine:
git clone https://github.com/your-username/youtube-api-search.git
-
Navigate to the repository's directory:
cd youtube-api-search
-
Replace
'YOUR_API_KEY'
with your actual YouTube API key in thescript.py
file. -
Run the script using your Python interpreter:
python script.py
The script.py
file in this repository contains the sample code to search for videos using the YouTube API. The script performs the following steps:
- Imports the necessary libraries.
- Initializes the YouTube API client with your API key.
- Defines a search query.
- Calls the
search.list
method to retrieve search results for videos. - Prints video information (title and video ID) from the search results.
The script can be easily customized for your use case, allowing you to explore more YouTube API features.
Video Title: Python Programming Tutorial - 1 | Python Tutorial For Beginners | Python Training | Edureka
Video ID: WGJJIrtnfpk
------------------------------
Video Title: Python Tutorial for Beginners [Full Course] 2019
Video ID: HBxCHonP6Ro
------------------------------
...
Please ensure that you handle your API keys securely and follow YouTube's API terms of service and usage guidelines. This example provides a starting point for using the YouTube API for video searches.
For more detailed information about the YouTube Data API and its capabilities, refer to the official documentation.