Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/gagan-jasuja/youtube-api

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/gagan-jasuja/youtube-api

  • v0.0.0-20241104113141-89e6d99fd90e
  • Source
  • Go
  • Socket score

Version published
Created
Source

YouTube API Application

This is a simple Go application that interacts with the YouTube API to fetch and store video data in MongoDB. The application provides a RESTful API to retrieve videos and perform searches based on titles and descriptions.

Features

  • Fetch the latest videos from YouTube using a predefined search query.
  • Store video details such as title, description, publish date, and thumbnail URL in MongoDB.
  • Retrieve a paginated list of stored videos.
  • Search for videos by title and description.

Technologies Used

  • Go (Golang)
  • MongoDB (MongoDB Atlas or local instance)
  • Gorilla Mux for routing
  • Postman for API testing

Getting Started

Prerequisites

  • Go installed on your machine (1.16+)
  • MongoDB instance (Atlas or local)
  • Postman (for testing APIs)

Installation

  1. Clone the repository:

    git clone https://github.com/gagan-jasuja/youtube-api.git
    cd your-repo-name
    
  2. Set up your environment variables in a .env file:

    MONGODB_URI=your_mongodb_uri
    
  3. Install the necessary dependencies:

    go mod init youtube-api
    go mod tidy
    

Running the Application

  1. Start the application:

    go run ./cmd/main.go
    
  2. The application will run on http://localhost:8080.

API Endpoints

1. Get Paginated Videos
  • URL: /videos?page=1&limit=10
  • Method: GET
  • Description: Retrieves a paginated list of videos sorted by publish date in descending order.
2. Search Videos
  • URL: /search?query=your_search_query
  • Method: GET
  • Description: Searches for videos based on title or description.

Testing with Postman

You can test the API using Postman by following these steps:

  1. Open Postman.
  2. Create a new request.
  3. Set the HTTP method (GET) and enter the API endpoint URL.
  4. Click "Send" to make the request and view the response.

Example Requests

Fetch Videos:

GET http://localhost:8080/videos?page=1&limit=10

Search Videos:

GET http://localhost:8080/search?query=Movies

License

Primary_Owner - Gagan Jasuja

Acknowledgements

  • YouTube Data API
  • MongoDB

FAQs

Package last updated on 04 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc