ytube-api
YouTube API v3 implementation for NodeJS
Requirement
API Key. To create API Key follow the steps https://cloud.google.com/docs/authentication/api-keys
Usage:
Installation
npm install ytube-api
Example
List category videos based on Region:
const youTube = new YouTube();
youTube.setKey('API_KEY');
youTube.getMostPopularByCategoryAndRegion(2, 10, 'AU', function(error, result) {
if (error) {
console.log(error);
} else {
console.log(JSON.stringify(result, null, 2));
}
});
Get Channel details by IDs
const youTube = new YouTube();
youTube.setKey('API_KEY');
const channelIds = [
"UC_x5XG1OV2P6uZZ5FSM9Ttw",
"UC29ju8bIPH5as8OGnQzwJyA"
]
youTube.getChannelById(channelIds, (err, response) => {
if (err) console.log(err);
console.log(JSON.stringify(response));
});
Get Video details by ID.
const youTube = new YouTube();
youTube.setKey('API_KEY');
const Ids = [
"---KhTqjC4M",
]
youTube.getById(Ids, (err, response) => {
if (err) console.log(err);
console.log(JSON.stringify(response));
});
To set an optional parameter use:
youTube.addParam('order', 'title');
Documentation
The official Youtube documentation is a very useful resource as a reference.
- getChannelById
- getPlayListsById
- getPlayListsItemsById
- search
- related
- getMostPopular
- getMostPopularByCategory
- getMostPopularByCategoryAndRegion
Help
- For bug reports and feature requests, open issues.