Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Pragyat-Nikunj/VidTube/llms.txt

Use this file to discover all available pages before exploring further.

VidTube runs on Node.js and MongoDB. This guide walks you through setting up a local instance and making your first real API calls — from a healthcheck all the way to fetching your profile with a bearer token. If you just want to explore endpoints without any setup, skip straight to the live demo.

Prerequisites

  • Node.js v14 or later
  • MongoDB — a local instance or a connection string from MongoDB Atlas
  • npm or yarn

Set up a local instance

1

Clone the repository and install dependencies

git clone https://github.com/Pragyat-Nikunj/VidTube.git
cd VidTube
npm install
2

Create your environment file

Copy the template below into a .env file in the project root. See Environment variables for a description of every value.
NODE_ENV=development
PORT=3001
CORS_ORIGIN=*
MONGODB_URL=mongodb://localhost:27017/vidtube

# JWT
ACCESS_TOKEN_SECRET=your_access_token_secret
ACCESS_TOKEN_EXPIRY=1h
REFRESH_TOKEN_SECRET=your_refresh_token_secret
REFRESH_TOKEN_EXPIRY=10d

# Cloudinary
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
CLOUDINARY_* values are required for video and avatar uploads. Create a free account at cloudinary.com to get them. See Cloudinary setup for details.
3

Start the server

npm run dev
The server starts at http://localhost:3001 (or whichever PORT you set). npm run dev uses Nodemon and restarts automatically on file changes.

Use the live demo

You can test the public API without running anything locally. All examples below use the hosted base URL:
https://vidtube-ke5w.onrender.com/api/v1

Make your first API calls

1. Healthcheck

Verify the API is up before making other requests.
curl https://vidtube-ke5w.onrender.com/api/v1/healthcheck

2. List videos

Fetch all published videos — no authentication required.
curl https://vidtube-ke5w.onrender.com/api/v1/videos/getAllVideos

3. Register a user

Registration requires multipart/form-data because you upload an avatar image alongside the text fields. avatar is required; coverImage is optional.
curl -X POST https://vidtube-ke5w.onrender.com/api/v1/users/register \
  -F "username=johndoe" \
  -F "email=john@example.com" \
  -F "password=secret123" \
  -F "fullname=John Doe" \
  -F "avatar=@/path/to/avatar.jpg"
A successful response returns HTTP 201 and the new user object (password and refresh token are excluded).

4. Log in

Send email, username, and password as JSON. The response contains both accessToken and refreshToken in the body and as httpOnly cookies.
curl -X POST https://vidtube-ke5w.onrender.com/api/v1/users/login \
  -H "Content-Type: application/json" \
  -d '{"email":"john@example.com","username":"johndoe","password":"secret123"}'
{
  "statusCode": 200,
  "data": {
    "user": { "username": "johndoe", "email": "john@example.com", "fullname": "John Doe" },
    "accessToken": "eyJ...",
    "refreshToken": "eyJ..."
  },
  "message": "User logged In successfully",
  "success": true
}
Save the accessToken value — you need it for protected endpoints.

5. Call a protected endpoint

Pass the access token as a Bearer token in the Authorization header.
curl https://vidtube-ke5w.onrender.com/api/v1/users/current-user \
  -H "Authorization: Bearer eyJ..."
{
  "statusCode": 200,
  "data": {
    "_id": "...",
    "username": "johndoe",
    "email": "john@example.com",
    "fullname": "John Doe",
    "avatar": "https://res.cloudinary.com/..."
  },
  "message": "Current user details",
  "success": true
}

Next steps

Authentication

Learn how to refresh tokens, handle expiry, and log out cleanly.

Video uploads

Upload videos and thumbnails, and toggle publish status.

Social interactions

Add likes, comments, tweets, and manage subscriptions.

Channel dashboard

Pull channel stats: views, subscribers, video count, and likes.

Build docs developers (and LLMs) love