Coder Social home page Coder Social logo

batman004 / youtube-proxy-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 44 KB

A proxy API to continuously poll the YouTube API, persist responses in realtime, and perform fuzzy search on stored records with rate limiting implemented

Home Page: https://documenter.getpostman.com/view/16798044/UzQxNjVZ

License: MIT License

Python 95.73% Dockerfile 2.48% Shell 1.79%
fastapi mongodb proxy-api rate-limiting youtube-api

youtube-proxy-api's Introduction

Tech Stack

  • Python(FastAPI)
  • MongoDB cloud Atlas

Directory Structure

.
├── LICENSE
├── README.md
├── app
│   ├── Dockerfile
│   ├── __init__.py
│   ├── api
│   │   ├── __init__.py
│   │   ├── config.py
│   │   └── videos
│   │       ├── __init__.py
│   │       ├── auth
│   │       │   ├── __init__.py
│   │       │   └── auth_helper.py
│   │       ├── endpoints
│   │       │   ├── __init__.py
│   │       │   ├── models.py
│   │       │   └── routers.py
│   │       ├── handlers
│   │       │   ├── __init__.py
│   │       │   ├── data_search_handler.py
│   │       │   └── youtube_data_helper.py
│   │       └── utils
│   │           └── latest_video_data.py
│   ├── main.py
│   └── requirements.txt
└── run.sh

Database Schema

video

    _id: int
    publishedAt: str
    channelId: str
    title: str
    description: str
    thumbnails: dict
    channelTitle: str
    liveBroadcastContent: str
    publishTime: str

    "example":{

          "_id": "wqjq2m1EQy8",
          "publishedAt": "2022-07-17T04:39:58Z",
          "channelId": "UCyrHueZqBqzCPizy4qYIV5A",
          "title": "LOOK at these INSANE DRIBBLES 🥶🥶🔥#shorts  #football",
          "description": "Make Money watching youtube videos - https://youtu.be/CnLweYfBKeY funniest football youtube channel ...",
          "thumbnails": {
            "default": {
              "url": "https://i.ytimg.com/vi/wqjq2m1EQy8/default.jpg",
              "width": 120,
              "height": 90
            },
            "medium": {
              "url": "https://i.ytimg.com/vi/wqjq2m1EQy8/mqdefault.jpg",
              "width": 320,
              "height": 180
            },
            "high": {
              "url": "https://i.ytimg.com/vi/wqjq2m1EQy8/hqdefault.jpg",
              "width": 480,
              "height": 360
            }
          },
          "channelTitle": "Skill District",
          "liveBroadcastContent": "none",
          "publishTime": "2022-07-17T04:39:58Z"
      }

API Routes

videos Module

Routes HTTP Description
/video/ GET Get all videos
/video/search/{title} GET Get video data based on title
/video/search/{description} GET Get video data based on description
/video/ POST add videos to DB

Steps to run

Open terminal and run the following commands

git clone https://github.com/batman004/YouTube-Proxy-Api
cd YouTube-Proxy-Api

add a .env file inside ./app (refer .env.example)

#fill in credentials :
    DB_URL=
    DB_NAME=
    PORT=
    API_KEY=

setting up a databse

  • Create an Atlas account. Register for an Atlas account using your Google Account or an email address.
  • Deploy a free cluster.
  • Add your connection IP address to your IP access list.
  • Create a database user for your cluster.
  • Connect to your cluster via the DB URI provided (refer Docs)

run the run.sh script to Dockerize the project and run it

sh run.sh

The server will start running at port:80

Sample payloads

⚠️ Current limit is set to 5 requests/api-key

  1. Getting the API-KEY
curl --location --request GET 'localhost:80/api-key'
  1. Adding Videos to the DB
curl --location --request POST 'localhost:80/video?keyword=football&iterations=2' \
--header 'Authorization: Bearer {{token}}'

  1. Fetching video data from DB
curl --location --request GET 'localhost:80/video?page=1&size=3' \
--header 'Authorization: Bearer {{token}}'

  1. Searching based on video title
curl --location --request GET 'localhost:80/video/search/football/?page=1&size=10' \
--header 'Authorization: Bearer {{token}}'
  1. Search based on video description
curl --location --request GET 'localhost:80/video/search/football and messi/?page=1&size=10' \
--header 'Authorization: Bearer {{token}}'

Available Features 🍻

  • Add data to DB in async manner after recieving interval and keyword from user
  • API Key support to authenticate user and limit calls 🔐
  • View all entries with pagination settings available 🗒️
  • Fuzzy search based on title and description of video ✍️

youtube-proxy-api's People

Contributors

batman004 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.