A simple wrapper for the Youtube Downloader CC API for downloading YouTube videos as MP3 or MP4.
A simple and easy-to-use Node.js package that allows you to download YouTube videos as MP3 or MP4 and updated in March 21 2025. Built and maintained by Jonell Magallanes.
---
First, install the package using npm:
``bash`
npm install youtube-downloader-cc-api
This will automatically install all required dependencies.
---
ā
Download YouTube videos as MP3 (audio) or MP4 (video)
ā
Choose between two response types:
- "stream" ā Returns a JSON response with a download link
- "direct" ā Automatically downloads the file locally
ā
Fast and simple API for developers
---
Before using the downloader, you need to import the function:
`javascript`
const { getDownloadDetails } = require("youtube-downloader-cc-api");
---
Now, call the function with three parameters:
- YouTube URL ā The video you want to download
- Type ā Choose "mp3" for audio or "mp4" for video "stream"
- Response Type ā for JSON output or "direct" to auto-download
---
If you only need the download link, use the "stream" response type:
`javascript
const { getDownloadDetails } = require("youtube-downloader-cc-api");
(async () => {
try {
const url = "https://youtu.be/Rb1HSnuR8WE"; // Replace with your YouTube link
const type = "mp3"; // Choose "mp3" or "mp4"
const responseType = "stream"; // Get the JSON response (link only)
const response = await getDownloadDetails(url, type, responseType);
console.log("Download Details:", response);
} catch (error) {
console.error("Error:", error.message);
}
})();
`
If responseType is "stream", the function returns a JSON object like this:
`json`
{
"url": "https://youtu.be/Rb1HSnuR8WE",
"download": "https://yt-downloader-ccprojects-production.up.railway.app/download/1737550613.mp3",
"title": "Family Guy Funny Spelling",
"response": "Time Response: Wed Jan 22 12:56:57 2025",
"author": "Jonell Hutchin Magallanes"
}
š¹ Best for: Developers who want to display the download link to users instead of downloading the file directly.
---
If you want to automatically download the video or audio file, use the "direct" response type:
`javascript
const { getDownloadDetails } = require("youtube-downloader-cc-api");
(async () => {
try {
const url = "https://youtu.be/Rb1HSnuR8WE"; // Replace with your YouTube link
const type = "mp4"; // Choose "mp3" or "mp4"
const responseType = "direct"; // Auto-download the file
const response = await getDownloadDetails(url, type, responseType);
console.log(ā
File saved at: ${response.path});`
} catch (error) {
console.error("Error:", error.message);
}
})();
If responseType is "direct", the function will automatically download the file to your local machine:
`bash`
Downloading [####################] 100% | 8.6MB/8.6MB bytes
ā
Download complete!
File saved at: /your/path/downloaded_file.mp4
š¹ Best for: Users who want to instantly download the video/audio without extra steps.
---
This function fetches the download details for a given YouTube video.
| Parameter | Type | Required | Description |
|---------------|--------|----------|----------------------------------------------------------|
| url | String | Yes | The YouTube video URL. |type
| | String | Yes | Choose "mp3" for audio or "mp4" for video. |responseType
| | String | Yes | "stream" (get link as JSON) or "direct" (auto-download). |
---
The required dependencies are automatically installed, but if needed, you can manually install them:
`bash`
npm install axios cli-progress fs path
---
When you run the example code, you will see output like this:
For stream response type:
`json`
{
"url": "https://youtu.be/Rb1HSnuR8WE",
"download": "https://yt-downloader-ccprojects-production.up.railway.app/download/1737550613.mp3",
"title": "Family Guy Funny Spelling",
"response": "Time Response: Wed Jan 22 12:56:57 2025",
"author": "Jonell Hutchin Magallanes"
}
For direct response type:
`bash``
Downloading [####################] 100% | 8.6MB/8.6MB bytes
ā
Download complete!
File saved at: /your/path/downloaded_file.mp4
---
This Main Server of Youtube DL CC visit https://jonell01-youtube-dl-ccapi-hutchin.hf.space/ for more info
---
The YouTube Downloader CC API makes it easy and efficient to download YouTube videos in MP3 or MP4 format. Whether you want to get a download link or automatically save the file, this library is built to be simple and developer-friendly.
š Start using it today and integrate YouTube downloads into your projects!
---
Join the Chatbot Community Group on Facebook to connect with other developers:
š Chatbot Community
---
šļø Special Thanks:
š” Salamat sa CCPRAKJIK 19 na commands ko š¤