/YouTube-Node

This is a fast and modern API for downloading videos, audios, thumbnails, and getting video information from YouTube. It's built with Node.js and uses the ytdl-core library to interact with YouTube.

Primary LanguageJavaScriptMIT LicenseMIT

YouTube API

This is a fast and modern API for downloading videos, audios, thumbnails, and getting video information from YouTube. It's built with Node.js and uses the ytdl-core library to interact with YouTube.

Installation

To install and run this project, follow these steps:

  1. Clone the repository:
git clone https://github.com/ReactMVC/YouTube-Node.git
  1. Navigate into the project directory:
cd YouTube-Node
  1. Install the dependencies:
npm install
  1. Start the server:
npm start

The server will start running on port 3000.

Usage

This API provides two endpoints, both of which accept a YouTube URL and return information about the video.

GET Request

To send a GET request, use the /api endpoint and include the YouTube URL as a query parameter:

fetch('http://localhost:3000/api?url=YOUR_YOUTUBE_URL')
  .then(response => response.json())
  .then(data => console.log(data));

POST Request with Fetch

fetch('http://localhost:3000/api', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ url: 'YOUR_YOUTUBE_URL' }),
})
  .then(response => response.json())
  .then(data => console.log(data));

POST Request with Axios

const axios = require('axios');

axios.post('http://localhost:3000/api', {
  url: 'YOUR_YOUTUBE_URL'
})
.then(function (response) {
  console.log(response.data);
})
.catch(function (error) {
  console.error(error);
});

cURL Command for POST Request

You can also use cURL to send a POST request:

curl -X POST -H "Content-Type: application/json" -d '{"url":"YOUR_YOUTUBE_URL"}' http://localhost:3000/api

Response

The API will return a JSON object containing information about the video, including the title, description, view count, channel details, publish date, update date, embed details, thumbnails, and available formats.

Demo

You can try out the API at the following demo URL:

https://youtube.reactmvc.repl.co/api?url=YOUR_YOUTUBE_URL

Please replace youtube.reactmvc.repl.co with the actual URL where your API is hosted, and replace YOUR_YOUTUBE_URL with the URL of the YouTube video you want to get information about.

For example, if your API is hosted at api.example.com and you want to get information about the video at https://www.youtube.com/watch?v=dQw4w9WgXcQ, you would use the following URL:

http://api.example.com/api?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ

Developer Contact

For any queries or suggestions, you can reach out to the developer:

License

This project is licensed under the MIT License.