youtube-api

A Node.JS module, which provides an object oriented wrapper for the Youtube v3 API.

Youtube API

A Node.JS module, which provides an object oriented wrapper for the Youtube v3 API.

Install with the Node.JS package manager npm:

$ npm install youtube-api

or

Install via git:

$ git clone git://github.com/IonicaBizau/youtube-api.git
cd youtube-api
$ npm install

The official Youtube documentation is a very useful resource.

If you have any questions, just open an issue.

var Youtube = require("youtube-api");
 
Youtube.authenticate({
    type: "oauth"
  , token: ACCESS_TOKEN
});
 
// List your channels
Youtube.channels.list({
    "part": "id"
  , "mySubscribers": true
  , "maxResults": 50
}, function (err, data) {
    console.log(err || data);
});
 
// Add a Video to a playlist
Youtube.playlistItems.insert({
    "part": "snippet"
  , "resource": {
      "playlistId": "YouTube Playlist ID"
    , "resourceId": {
       "videoId": "YouTube Video ID"
     , "kind": "youtube#video"
      }
    }
});
Youtube.authenticate({
    type: "oauth"
  , token: "your access token"
});
Youtube.authenticate({
    type: "key"
  , key: "your server key"
});
Youtube.authenticate({
    type: "jwt"
  , email: "77....3vv@developer.gserviceaccount.com"
  , keyFile: "... auth.pem"
  , key: "fb....d50"
  , subject: "you@gmail.com" // optional
  , scopes: ["https://www.googleapis.com/auth/youtube"]
}).authorize(function (err, data) {
    if (err) { throw err; }
    /* Access resources */
});

Download and test this module using this test application.

Note that a connection to the internet is required to run the tests.

See package.json file.

Help the youtube-api NPM package development. Any donation is welcome and I will be thankful!

MIT license. See the LICENSE file for details.

  • Insert request example in README.
  • Fixes in documentation
  • JWT authentication type
  • All request types are supported (using googleapis)
  • Deprecacted setConfig method
  • Removed debugging message from index.js
  • Output an error in application logs if there is an unkwnown error in request
  • Minor fix in util.js
  • Added the key authentication.

    Example:

    Youtube.authenticate({
        type: 'key'
      , key: 'AIz...OtE'
    });
  • Fixed #2 (pull request): fix in videos API requests.
  • Initial release
  • Supports only GET requests