API and frontend for media search tool
Youtube Data API key
- Create a project in the Google Cloud Console
- On the new project dashboard, click
APIs & Services
thenEnable APIs and Services
. - Search for and enable
Youtube Data API v3
- Click
Create Credentials
and selectpublic data
- Add the API key to the .env file in the root of the project
- Clone the repository
- cd into the repository
- Run
make run
to start the app
App will run on http://127.0.0.1:5000
Tests can be run with make tests
The API has the following endpoints:
- /api/v1/shorts - GET - Returns urls of short videos
- /api/v1/images - GET - Returns urls of images
query parameters:
- search_term: The search term to search for
- max_results: The maximum number of results to return
Example: http://127.0.0.1:5000/api/v1/shorts?search_term=cats&max_results=5
returns
{
"urls": [
"https://www.youtube.com/watch?v=3bhkYoMWTFE",
"https://www.youtube.com/watch?v=NsMKvVdEPkw",
"https://www.youtube.com/watch?v=Op3NJrb3mFg",
"https://www.youtube.com/watch?v=5WwVTuQmmkg",
"https://www.youtube.com/watch?v=BvJ0DVSFHkk"
]
}
You may find that some embedded YouTube videos are showing "Video unavailable" when you try and view them in the app, like this: The reason for this may be that they have copyrighted music in the background and for copyright reasons, YouTube automatically blocks these from playing if the EMBED setting is ON.