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

youtube-api-thumbnails

v1.1.1

Published

Requests Youtube API for all thumbnails related to Youtube Video IDs

Downloads

3

Readme

youtube-api-thumbnails

Get Youtube thumbnails via Youtube API

Before you start

Follow the official Google tutorial to obtain API KEY

  1. You need a Google Account to access the Google API Console, request an API key, and register your application.

  2. Create a project in the Google Developers Console and obtain authorization credentials so your application can submit API requests.

  3. After creating your project, make sure the YouTube Data API is one of the services that your application is registered to use:

    • Go to the Developers Console and select the project that you just registered.
    • Open the API Library in the Google Developers Console. If prompted, select a project or create a new one. In the list of APIs, make sure the status is ON for the YouTube Data API v3.
  4. In Credentials in left menu you can generate your API key

Instalation

$ npm install youtube-api-thumbnails

Usage

Call the module

var thumbnails = require('youtube-api-thumbnails');

Configuration

thumbnails.config({
  	key: "<your Youtube API key>",	// required
    returnAsArray: true,			// optional, default is false
	onlyHighestRes: true,			// optional, default is false
	getResolutions: true			// optional, default is false
})

Get Youtube video thumbnails

thumbnails.get(id, callback);

id

Array of youtube videos ID

callback( err, thumbnails )

If error appears err contains error message else is null.

thumbnails is an object with videos ID and links to their thumbnails. Check examples for more information

Examples

thumbnails.get([ 'aaa' , 'Z0ZUwh8GOo0' , 'Rh9a1ICbIJE' ], function (err, thumbnails) {
    if(err){
      console.log(err);
      return;
    }

    console.log(thumbnails);
});

Only existing videos will appear in result so video ID 'aaa' will be missing

Result

With default configuration ( only key set )

[
	Z0ZUwh8GOo0: {
    	default: 'https://i.ytimg.com/vi/Z0ZUwh8GOo0/default.jpg',
    	medium: 'https://i.ytimg.com/vi/Z0ZUwh8GOo0/mqdefault.jpg',
    	high: 'https://i.ytimg.com/vi/Z0ZUwh8GOo0/hqdefault.jpg',
    	standard: 'https://i.ytimg.com/vi/Z0ZUwh8GOo0/sddefault.jpg' },
  	Rh9a1ICbIJE: {
  		default: 'https://i.ytimg.com/vi/Rh9a1ICbIJE/default.jpg',
    	medium: 'https://i.ytimg.com/vi/Rh9a1ICbIJE/mqdefault.jpg',
    	high: 'https://i.ytimg.com/vi/Rh9a1ICbIJE/hqdefault.jpg',
    	standard: 'https://i.ytimg.com/vi/Rh9a1ICbIJE/sddefault.jpg',
    	maxres: 'https://i.ytimg.com/vi/Rh9a1ICbIJE/maxresdefault.jpg' }
]

If returnAsArray is set to true in config

[
	Z0ZUwh8GOo0: [
    	'https://i.ytimg.com/vi/Z0ZUwh8GOo0/default.jpg',
    	'https://i.ytimg.com/vi/Z0ZUwh8GOo0/mqdefault.jpg',
    	'https://i.ytimg.com/vi/Z0ZUwh8GOo0/hqdefault.jpg',
    	'https://i.ytimg.com/vi/Z0ZUwh8GOo0/sddefault.jpg' ],
  	Rh9a1ICbIJE: [
    	'https://i.ytimg.com/vi/Rh9a1ICbIJE/default.jpg',
    	'https://i.ytimg.com/vi/Rh9a1ICbIJE/mqdefault.jpg',
    	'https://i.ytimg.com/vi/Rh9a1ICbIJE/hqdefault.jpg',
    	'https://i.ytimg.com/vi/Rh9a1ICbIJE/sddefault.jpg',
    	'https://i.ytimg.com/vi/Rh9a1ICbIJE/maxresdefault.jpg' ]
]

If onlyHighestRes and getResolutions are set to true in config

[
	Z0ZUwh8GOo0: {
    	url: 'https://i.ytimg.com/vi/Z0ZUwh8GOo0/sddefault.jpg',
    	width: 640,
   		height: 480 },
  	Rh9a1ICbIJE: {
    	url: 'https://i.ytimg.com/vi/Rh9a1ICbIJE/maxresdefault.jpg',
    	width: 1280,
    	height: 720 }
]

Version

1.0.1

License

MIT