Skip to content

The Video Hosting Platform API is a backend system designed for a YouTube-like platform, offering RESTful APIs for user, video, subscription, playlist, comment, and like management. It supports user authentication, video upload, and metadata handling, including comments and likes. The platform enables video search, sorting, and pagination, as well

License

Notifications You must be signed in to change notification settings

The-Wee-Lad/Video-Hosting-Platform-API

Repository files navigation

Video Hosting Platform API

I have made a generic VideoHosting backend for "Youtube" like System.

This repository contains the core backend code that provides RESTful APIs for managing users, videos, comments, likes, and other essential operations. Designed with performance and scalability in mind, this system is built to handle growing traffic and user interaction while ensuring robust security measures.

There Are 30+ End points, for all of them Import this Postman Collection from ./VideoHosting-Backend.postman_collection.json. 😁



Features

  • User Management

    • User registration and authentication (email/password) -login, logout, remove user,
  • Subscrition -Users can subscribe other users

  • Video Management

    • Upload, update, and delete videos.
    • Support for video metadata (e.g., title, description).
  • Comments and Likes

    • user can comment and like a Video
  • Search

    • Search videos by title or description
    • sort searches by duration, views, date
    • active pagination
  • Playlist

    • playlist of videos can be made
  • Privacy

    • a video can have comments on off options
    • a video can be public, private
    • subscription list and can be made private

Installation

Prerequisites

  1. Node.js (v16.x or higher).
  2. MongoDb (v8.x or higher).
  3. Mongoose (as ODM).
  4. Express (4.x) installed on the server.
  5. Cloudinary for cloud storage.

Steps

  1. Clone the repository:
    git clone https://github.com/The-Wee-Lad/Video-Hosting-Platform
    cd video-hosting-backend
  2. Installing Dependencies
    npm install
    
  3. Environment Setup
    PORT=8000
    MONGODB_URI=Your Mongo url
    CORS_ORIGIN=*
    ACCESS_TOKEN_SECRET= use rendom string generators
    ACCESS_TOKEN_EXPIRY="1h"
    REFRESH_TOKEN_SECRET=a refresh Token secret
    REFRESH_TOKEN_EXPIRY="1d"

    #I used cloudinary for hosting user profile   pics, coverImage, and videos themselves.

    CLOUDINARY_CLOUD_NAME=clodinary cloud name
    CLOUDINARY_API_KEY=its api key
    CLOUDINARY_API_SECRET=its secret
    CLOUDINARY_URL=not really needed
  1. Run Node Development
    npm run dev
  2. Access Api At
    http://localhost:<port>
    
    

API Endpoints

All routes are protected by JWT Authentication.
The verifyJWT middleware ensures that only authenticated users can access these endpoints.

User Endpoints

Authentication
  • Register User:
    POST /user/register
    
  • Login User:
    POST /user/login
    
  • Refresh Access Token:
    POST /user/refresh-accessToken
    
  • Logout:
    POST /user/logout
    
  • Change Password:
    POST /user/change-pass
    
User Profile
  • Get Current User:
    GET /user/getcurruser
    
  • Update Account Details:
    PUT /user/update-acc-details
    
  • Update Avatar:
    PUT /user/update-avatar
    
  • Update Cover:
    PUT /user/update-cover
    
Channel & Activity
  • Channel Info:
    GET /user/channel/:channelName
    
  • Watch History:
    GET /user/watch-history
    
  • Toggle Subscription Privacy Policy:
    PUT /user/toggleSubsPrivacy
    
Deletion & Removal
  • Remove User:
    DELETE /user/remove-user
    
  • Remove Cover Image:
    DELETE /user/remove-cover
    
  • Remove Avatar:
    DELETE /user/remove-avatar
    

Video Endpoints

Video Upload & Retrieval
  • Publish Video:
    POST /vid/
    
  • Get All Videos: : (With Various Search criteria for more details see postman collection) :
    GET /vid/
    
Video Operations
  • Get Video by ID:
    GET /vid/:videoId
    
  • Update Video:
    PATCH /vid/:videoId
    
  • Delete Video:
    DELETE /vid/:videoId
    
Toggle Features
  • Toggle Video Publish Status:
    POST /vid/toggle-publish/:videoId
    
  • Toggle Comments on Video:
    POST /vid/toggle-comments/:videoId
    

Subscription Endpoints

Manage Subscriptions
  • Toggle Subscription to a Channel:
    POST /subs/c/:channel
    
  • Get Subscribed Channels:
    GET /subs/c/:channel
    
Subscriber Information
  • Get My Subscribers:
    GET /subs/my-subscribers
    

Playlist Endpoints

Playlist Management
  • Create Playlist:

    POST /playlist/
    
  • Get Playlist By ID:

    GET /playlist/:playlistId
    
  • Update Playlist:

    PATCH /playlist/:playlistId
    
  • Delete Playlist:

    DELETE /playlist/:playlistId
    
Video in Playlist
  • Add Video to Playlist:

    PATCH /playlist/add/:videoId/:playlistId
    
  • Remove Video from Playlist:

    PATCH /playlist/remove/:videoId/:playlistId
    
User Playlists
  • Get User Playlists:
    GET /playlist/user/:userId
    

Like/Dislike Endpoints

Toggle Like on Content
  • Toggle Like on Video:

    POST /like/toggle/v/:videoId
    
  • Toggle Like on Comment:

    POST /like/toggle/c/:commentId
    
Liked Content
  • Get ALl User Liked Videos:
GET /like/videos

Comment Endpoints

Manage Comments
  • Get Comments for a Video:

    GET /comment/:videoId
    
  • Add Comment to a Video:

    POST /comment/:videoId
    
Update/Delete Comment
  • Delete Comment:

    DELETE /comment/c/:commentId
    
  • Update Comment:

    PATCH /comment/c/:commentId
    

ALL the API Endpoints of Videos, Subscriptions, Playlists, Likes, and Comments are in the Postman Collection. For all input formats and More Endpoints Refer to it.

Folder Structure

Click Here To expand
Video-Hosting-Platform
├── SRC
│   ├── controllers
│   │   ├── comment.controller.js
│   │   ├── healthcheck.controller.js
│   │   ├── like.controller.js
│   │   ├── playlist.controller.js
│   │   ├── subscription.controller.js
│   │   ├── user.controller.js
│   │   └── video.controller.js
│   ├── db
│   │   └── index.js
│   ├── middlewares
│   │   ├── auth.middleware.js
│   │   └── multer.middleware.js
│   ├── models
│   │   ├── comments.model.js
│   │   ├── likes.model.js
│   │   ├── playlists.model.js
│   │   ├── subscriptions.model.js
│   │   ├── users.model.js
│   │   └── videos.models.js
│   ├── public
│   │   └── temp
│   ├── routes
│   │   ├── comment.routes.js
│   │   ├── healthcheck.routes.js
│   │   ├── like.routes.js
│   │   ├── playlist.routes.js
│   │   ├── subscription.routes.js
│   │   ├── user.routes.js
│   │   └── video.routes.js
│   └── utilities
│       ├── ApiError.js
│       ├── ApiResponse.js
│       ├── asyncHandler.js
│       └── cloudinary.js
├── app.js
├── constants.js
├── index.js
├── .env
└── readme.md

Technologies Used


Database Schema Used :

About

The Video Hosting Platform API is a backend system designed for a YouTube-like platform, offering RESTful APIs for user, video, subscription, playlist, comment, and like management. It supports user authentication, video upload, and metadata handling, including comments and likes. The platform enables video search, sorting, and pagination, as well

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published