Skip to content

ashavijit/yt-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YouTube Video API

Project Overview

This project aims to create an API for fetching the latest YouTube videos based on a predefined search query, storing them in a database, and providing paginated responses through a GET API endpoint. The project is built using Django and includes features like continuous background fetching, support for multiple API keys, and scalability.

Setup Instructions

  1. Clone the repository:
git clone https://github.com/ashavijit/yt-api
cd yt-api
  1. Create a virtual environment and install dependencies:
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
  1. Set up the Django environment variables:

    • Create a .env file in the project directory.

    • Add the following environment variables to the .env file:

      SECRET_KEY=your_django_secret_key
      YOUTUBE_API_KEYS=your_api_key_1,your_api_key_2,your_api_key_3
      
  2. Apply migrations:

python manage.py migrate
  1. Start the Django server:
python manage.py runserver
  1. Access the API at http://localhost:8000/api/videos/.

API Endpoints

  • GET /api/videos/: Returns the stored video data in a paginated response sorted in descending order of published datetime.

Dashboard (Optional)

To access the dashboard for viewing stored videos with filters and sorting options:

  1. Ensure the Django server is running.
  2. Visit http://localhost:8000/admin/ in your browser.
  3. Log in with your admin credentials.
  4. Navigate to the "Videos" section.

Docker Instructions

  1. Build the Docker image:
docker build -t youtube-video-api .
  1. Run the Docker container:
docker run -p 8000:8000 youtube-video-api

Terraform Instructions

  1. Install Terraform from here.
  2. Navigate to the terraform directory:
cd terraform
  1. Initialize the Terraform working directory:
terraform init
  1. Create a terraform.tfvars file in the terraform directory and add the following variables:

    project = "your_project_id"
    region = "your_region"
    
  2. Apply the Terraform configuration:

terraform apply
  1. Access the API at http://<EXTERNAL_IP>:8000/api/videos/.

  2. Access the API at http://localhost:8000/api/videos/.

Contributing

Feel free to contribute to this project by submitting bug reports, feature requests, or pull requests.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Time Consumption

wakatime

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors