An application exposing an API that fetches the latest YouTube videos for a given topic. Latest YouTube videos pertaining to a topic are asynchronously fetched and populated in a database.
- api.key.list : Comma-separated api keys. Eg: key1,key2,key3
- video.fetch.topic : Topic of videos to be fetched. Eg: cricket
- video.fetch.interval : Interval for populating database with videos in ms. Eg: 30000
- spring.data.mongodb.host : Mongo service name for youtube-api-app to connect.
This application uses Docker Compose to start youtube-api-app and mongodb.
Optional: Pull the application image from DockerHub using the command:
$ docker pull dhanushkamath/youtube-api:1.0.0
Run the application with the command:
$ docker-compose up
Test the API with the included Postman collection - Postman
To scale youtube-api-app service, use:
$ docker-compose up --scale youtube-api-app=<number-of-containers>
src/main/java
- This folder contains the application source code.test/
- This folder contains the POSTMAN collection with all requests configured.
Returns a json response containing videos.
-
URL
/api/videos
-
Method:
GET
-
Query Params
text: [string]
| To search for videos with given text in video title and/or descriptionpage: [integer]
| The page numbersize: [size]
| The size of each page
-
URL Params
None
-
Notes
- If text is passed, response will contain best matches for the given text. Supports partial match as well.
- If page is passed, response will have pagination elements.