Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

youtube-comment-api

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

youtube-comment-api

Youtube comment API

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

Youtube Comment API

Build Status

Purpose

A Node.js API for the YouTube comment system. Scrapes comments and comment information from a given YouTube video on demand.

This project is in no way affiliated with YouTube.

Installation

Install as a module via npm.

$ npm install youtube-comment-api

Usage

http//www.youtube.com/watch?v={videoID}

var fetchCommentPage = require('youtube-comment-api')(config)
fetchCommentPage(videoID, pageToken, cb);
ParameterMeaning
config(optional) module coniguration
videoIDID of youtube Video
pageToken(optional) token of page to be requested
callback(optional) callback function

Promises API

var fetchCommentPage = require('youtube-comment-api')();
// request first page of comments (most recent)
fetchCommentPage('{videoID}').then(function (commentPage) {
  console.log(commentPage);
  return commentPage.nextPageToken;
}).then(function (pageToken) {
  // request next page
  return fetchCommentPage('{videoID}', pageToken)
}).then(function (commentPage) {
  console.log(commentPage);
});

Callback API

var fetchCommentPage = require('youtube-comment-api')();
// request first page of comments (most recent)
fetchCommentPage('{videoID}', function (err, commentPage) {
  if (err) throw err;
  console.log(commentPage);
  // request next page
  fetchCommentPage('{videoID}', commentPage.nextPageToken, function(err, commentPage) {
    if (err) throw err;
    console.log(commentPage);
  });
});

Configuration

Below are the possible configuration options and their default values.

{
  includeReplies: true,
  includeVideoInfo: true,
  sessionTimeout: 60 * 30, // 30 minutes
  cacheDuration: 60 * 30, // 30 minutes
  cacheInterval: 60 * 5 // 5 minutes
}
OptionMeaning
includeRepliesAlso fetch replies for each comment (default: true)
includeVideoInfoFetch meta information about video (default: true)
sessionTimeoutNumber of seconds after which the acquired session token is disgarded and a new one is requested. (default: 30 mins)
cacheDurationNumber of seconds after which cached video meta info will be disgarded (default: 30 mins)
cacheIntervalLength of the interval in seconds at which the video meta info cache entries are checked and disgarded if expired. (default 5 mins)

Result

{
  pageToken: {{ page token of current page }},
  nextPageToken: {{ page token of next page }},
  videoCommentCount: {{ number of comments on the video }},
  videoTitle: {{ video title }},
  videoThumbnail: {{ URL to video Thumbnail }},
  comments: [
	{
      id: {{ comment ID }},
      user: {{ username of author }},
      date: {{ how long ago the comment was posted }},
      commentText: {{ the comment }},
      timestamp: {{ timestamp based on date }},
      likes: {{ number of upvotes }},
      hasReplies: {{ whether this comment has replies }},
      numberOfReplies: {{ number of replies to the comment }},
      replies [
        {
          {{ ... same fields as comment }}
        },
        ...
      ],
      ...
    }
  ]
}

Keywords

FAQs

Package last updated on 23 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc