Giter VIP home page Giter VIP logo

youtube-api-app's Introduction

youtube-api-app

A simple real-time application built using the YouTube API v3 that searches for and displays videos related to your favourite topic.

The application fetches new data periodically and organizes it in a user-friendly Grafana dashboard that helps you to view and query your favourite videos.

screenshot of dashboard

How to use youtube-api-app

You can use the youtube-api-app by sending simple GET requests to the respective endpoints. For each request, you will receive corresponding video data, organised in the following key-value pairs:

Field Description
_id The unique ID of the YouTube video
channel_id The unique ID of the channel that posted the video
title The title of the YouTube video
description The description of the YouTube video
video_url The URL to the YouTube video
thumbnail_url The URL to the high resolution thumbnail of the YouTube video
published_at The timestamp (ISO 8601) at which the video was posted

A Postman collection has been included in the test/ directory. You can use it to test the application's endpoints.

Fetch Videos from Database

You can fetch paginated videos from the database by sending a GET request to the /fetch endpoint.

curl --location --request GET 'localhost:5000/fetch'

You can also specify a page_id to fetch a specific page of videos.

curl --location --request GET 'localhost:5000/fetch?page_id=1'

Response

Field Description
items A list of key-value mappings with details for each video
next_page_id A token to access the next page of results
page_id The current page's token

Search Videos

You can search for a video by sending a GET request to the /search endpoint with a title and description query parameter.

curl --location --request GET 'localhost:5000/search?title=dogs&description=cute and friendly'

Response

Field Description
items A list of key-value mappings with details for each video

View Dashboard

You can view the data in a Grafana dashboard by visiting localhost:3000 and navigating to the FamPay dashboard.

How to setup the application

  1. The first step is to download the fastText embedding model for query retrieval. You can download the pretrained models from here. Place both the .bin and .npy files in a folder named model/ in the root of the application.

  2. Create a .env file with the following variables.

    • Replace YOUTUBE_API_KEY with your own YouTube API key - you can follow the instructions here to get one
    • Leave GRAFANA_API_KEY empty for now - we will replace it later
    • If you would like to use a different database connection for the application, you can replace DATABASE_URL with your own connection string and DATABASE_* variables with the corresponding credentials
    YOUTUBE_API_KEY=""
    
    DATABASE_URL="postgresql://postgres:postgres@postgres:5432/postgres"
    DATABASE_USER="postgres"
    DATABASE_PASSWORD="postgres"
    DATABASE_HOST="postgres"
    DATABASE_PORT="5432"
    DATABASE_NAME="postgres"
    
    GRAFANA_URL="http://localhost:3000"
    GRAFANA_API_KEY=""
  3. While building the application, you can specify the following command line arguments. All of the arguments are optional and they will take their default values if no argument is provided. You can also change the default values arguments for the application in app/app.py

    Argument Default Description
    QUERY fampay Your query
    TIME 10 Time interval in minutes to fetch results
    MAX_RESULTS 5 Total number of results to return during search
    HOST 0.0.0.0 Host IP on which to run the application
    PORT 5000 Port number on which to run the application

    Specify the argument as VARIABLE=VALUE before the docker-compose command.

    Examples:

    QUERY=dogs docker-compose --project-name youtube-api-app up -d
    QUERY=cats TIME=3 MAX_RESULTS=10 docker-compose --project-name youtube-api-app up -d
  4. Visit localhost:3000 in your browser to view the Grafana dashboard. Navigate to Settings, and then API Keys. Generate a new API key with the Admin role.

  5. Access the grafana container using the following command:

    docker exec -it grafana bash
    • Open the .env file using the following command:
      vi .env
    • Move your cursor to the line containing GRAFANA_API_KEY. Press I to enter insert mode and then paste your API key here. Exit insert mode by pressing Esc on your keyboard. Finally save and exit using :wq.
    • Run the following command to setup the Grafana dashboard:
      ./setup/setup_grafana.sh
    • Exit the container by typing exit
    • Restart the grafana container using the following command:
      docker restart grafana
  6. Refresh the dashboard at localhost:3000 in your browser. You should see the dashboard with the videos that you searched for in the FamPay YouTube API Search dashboard directory.

youtube-api-app's People

Contributors

yashichawla avatar

Stargazers

 avatar Eny Tarunaditya avatar Aditeya Baral 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.