Skip to content

An API that fetches the latest YouTube videos for a given topic/search from a MongoDB database which gets updated asynchronously.

Notifications You must be signed in to change notification settings

dhanushkamath/youtube-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Youtube API

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.

RabbitMQ Mongo Docker


Table of Contents


Getting Started

Essential Environment Variables

  1. api.key.list : Comma-separated api keys. Eg: key1,key2,key3
  2. video.fetch.topic : Topic of videos to be fetched. Eg: cricket
  3. video.fetch.interval : Interval for populating database with videos in ms. Eg: 30000
  4. spring.data.mongodb.host : Mongo service name for youtube-api-app to connect.

Starting the API

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>

Code Overview

Application Structure

  • src/main/java - This folder contains the application source code.
  • test/ - This folder contains the POSTMAN collection with all requests configured.

API

GET /videos


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 description
    • page: [integer] | The page number
    • size: [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.

Authors

About

An API that fetches the latest YouTube videos for a given topic/search from a MongoDB database which gets updated asynchronously.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published