2.0.0 • Published 3 years ago
youtube-fetch v2.0.0
Install
npm install youtube-fetch
Importing
const data = require('youtube-fetch');
Or you could do import method put require is more better to use.
Docs
Example
const data = require('youtube-fetch');
async function example() {
const yt = await data.youtube('never gonna give you up');
const json = JSON.parse(yt);
//url, title, status, search, thumbnail, duration, upload_time, views, uploader, uploader_url
console.log(json.url);
}
example()
Handling Invalid Searches
You might have gotten a
json.url is undefined
But there is a simple fix! Just check if its undefined
if (json.url === undefined) {
console.log('invalid search')
return;
}
Although you could make the invalid search logging in console a diff thing if you want.
All data
If you just don't want urls you can change that! All options will be listed below
url,
title,
status,
search,
thumbnail,
duration,
upload_time,
views,
uploader,
uploader_url
Api
If your wondering what api we used its pretty simple: https://api.ducke.cf/
Author
dubfib