A NestJS API that uses @distube/ytdl-core to:
- fetch YouTube file info (title, author, description, thumbnails),
- list available formats (audio/video, itag, container, quality),
- and download the chosen format.
⚠️ For educational/personal use. Respect YouTube’s Terms of Service.
- 📄 Get video/audio metadata by YouTube ID.
- 🧩 List formats with
itag,container,quality,type. - ⬇️ Download video/audio by
fileId+itag. - ❤️ Health checks.
- NestJS (
@nestjs/common,@nestjs/core,@nestjs/platform-express) - @distube/ytdl-core for YouTube extraction
- Swagger via
@nestjs/swagger(served at /api-docs) - Jest for testing
- ESLint + Prettier for code quality
Prereqs: Node 18+ recommended, npm.
# 1) Install dependencies
npm install
# 2) Start in dev mode (watch)
npm run start:dev
# or start normally
npm run start
# 3) Open the app
# Base URL:
# http://localhost:3000
# Swagger UI:
# http://localhost:3000/api-docsOpen http://localhost:3000/api-docs and use Try it out:
- Go to GET
/youtube/get-file-info - Click Try it out
- Enter
id(YouTube ID, e.g.JzPfMbG1vrE) - Click Execute
- Inspect the response (title, description, thumbnails, etc.)
- Go to GET
/youtube/get-file-formats-info - Click Try it out
- Enter
id(e.g.JzPfMbG1vrE) - Enter
fileType(one of:audioandvideo,videoandaudio,video,videoonly,audio,audioonly) - Click Execute
- From the response, pick a format and note its
itag(and optionallycontainer,quality, etc.)
- Go to POST
/youtube/download-file - Click Try it out
- In the Request body, provide either:
{
"fileId": "JzPfMbG1vrE",
"itag": 18,
"type": "videoandaudio",
"quality": "medium",
"qualityLabel": "360p",
"container": "mp4",
"itag": 18
}Deepak Guptha Sitharaman
- GitHub: https://github.com/vzan2012
This project is licensed under the MIT License – see the LICENSE file for details.