npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

get-my-youtube-data

v2.0.2

Published

YouTube API helper to fetch user data

Downloads

3

Readme

Welcome to get-my-youtube-data!

This is a simple node helper to get all of a user's data from the youtube API

What you will need:

  • node 7.4 or higher To use async await

  • axios npm install axios --save

  • You Tube API key

put this API key somewhere safe. Do not publish it to github or deploy it. Bad things can happen.

  • Your You Tube id

    1. Sign in to your You Tube account.
    2. In the top right, click your account icon > settings .
    3. Next to your profile photo, click Advanced.
    4. You'll see your channel's user and channel IDs under "Account information."

How it works:

video Tutorial

  • add the package
const getYouTubeData = require('get-my-youtube-data');
  • get comments and video for a specific user This is where you should start. It will crawl the You Tube API and get all of the data you want.
let allResults = await getYouTubeData.gimmeAll( <youtubeUserID>, <yourAPIkey>)

console.log('all data for user', 
<youtubeUserId>, 'are: ', allResults)

this is what the results will look like:

allResults = {
  videos: [array of video objects],
  comments: [array of comment objects],
  uploadsPlaylist: "playlist ID string to get all videos,
  userId: "user ID string
}
  • New for 2.1.0

  • Reply to comment This one requires OAuth2. Not that hard to do. I made a tutorial for it if you need one.

click (here)[##sample-response] for sample response object for post.

let sentStatus = getYouTubeData.replyToComment(commentId, chanId, parentId, commentText, accessToken, refresh_token, <your youtube app ID>, <your youtube app secret> )
if ( !sentStatus  ) {
 console.log('Comment failed to post')
}

console.log( 'Comment posted. Response object is:', sentStatus )
  • get videos for a specific channel The channelId is usually the same as the userId. Unless the user has multiple channels
let channelVideos = await 
getYouTubeData.gimmeVideos(<channel-ID>, <yourAPIkey>)

console.log('all videos for channel', <uploads-ID>, 'are: ', channelVideos)
  • get all comments for a channel
let channelComments = await getYouTubeData.gimmeComments(<channel-ID>, <yourAPIkey>)

console.log('all comments for channel', <channel-ID>, 'are: ', channelComments)
  • get all videos for a specific playlist (use uploads to get all)

Every user has an "uploads" playlist. This playlist is made of every uploaded video. This id is usually similar to your user id. Your user id can start with "UC...", your uploads playlist can be the same, except it starts with "UU..."

let playlistVideos = await getYouTubeData.gimmePlaylist(<playlist-ID>, <yourAPIkey>)

console.log('all videos for playlist', <playlist-ID>, 'are: ', playlistVideos)

Also:

  • getPlaylists(<channel-ID>, <yourAPIkey>)
  • getChannelInfo(<channel-id>, <yourAPIkey>)

These return promises.

Sample response for posted comment reply:

{
  "kind": "youtube#comment",
  "etag": "\"ZG3FIn5B5vcHjQiQ9nDOCWdxwWo/zVHAtkB-3JGSE_y_ryQrkha7zv4\"",
  "id": "UgzVaKGXg9hhW03f9nR4AaABAg.8duZCr1njo98fOZ2O8S56k",
  "snippet": {
    "authorDisplayName": "ph8tel",
    "authorProfileImageUrl": "https://yt3.ggpht.com/-BtWgsj7pclE/AAAAAAAAAAI/AAAAAAAAAAA/114ywxrfdv8/s28-c-k-no-mo-rj-c0xffffff/photo.jpg",
    "authorChannelUrl": "http://www.youtube.com/channel/UCCooOt2LDAfz-5giM99biUQ",
    "authorChannelId": {
      "value": "UCCooOt2LDAfz-5giM99biUQ"
    },
    "textDisplay": "Testing automated reply to comment posted by user. -bot",
    "textOriginal": "Testing automated reply to comment posted by user. -bot",
    "parentId": "UgzVaKGXg9hhW03f9nR4AaABAg",
    "canRate": true,
    "viewerRating": "none",
    "likeCount": 0,
    "publishedAt": "2018-04-23T18:15:12.000Z",
    "updatedAt": "2018-04-23T18:15:12.000Z"
  }
}