To make an API to fetch latest videos sorted in reverse chronological order of their publishing date-time from YouTube for a given tag/search query in a paginated response.
- Django
- Django Rest Framework
- YouTube data v3 API
- HTML
- CSS
- Dockerfile
-
Download Docker desktop app from Here
-
To deploy this project, clone the repository
git clone https://github.com/Lekhanshlkr/youtube_search.git
- Go to the folder
cd youtube_search
- Modify
settings.py
File - Remove the existing key and add your own YouTube Data API key. Get a new API key from Here
YOUTUBE_DATA_API_KEY = <YOUR_KEY>
- Run the commands in
commands.txt
file in the given order.
-
Post Deployment, Go to Dashboard
-
You can search for the videos from the search tab.
-
On clicking
Youtube Search
, it will show the first 9 videos in reverse chronological order of their publishing date-time. -
On clicking
See all videos in table
, you will be redirected to the Rest Framework page where you can see all the stored videos in a paginated view with searching and sorting options.
HomePage
Search Results
Videos List View
Search and Filter Options
Database View in admin panel
API Usage Panel in Google Console
-
The API can be called continuously in background with some interval using
asyncio
and instead of fetching 9 results, it can be limited to 1-2 results per call. -
The search parameter
publishedAt
can be set to less than '30 minutes from current time' so that everytime the API is called, it only displays the results of videos which have been published in the last 30 minutes. -
A support for supplying multiple API keys can be added by supplying a 'list' in the
YOUTUBE_DATA_API_KEY
variable and then running a 'try except' block to check whether the API has been fully exhausted or not. -
Larger databases such as
PostgreSQL
andMySQL
can be used for handling large amounts of data storage. -
A job queue call using
Celery
can be implented, to handle multiple 'GET' request at the same time.
If you have any feedback, please reach out to me at [email protected]