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

google-ims

v1.1.4

Published

Search images using Google Images

Downloads

19

Readme

google-images

Provides a method in Node.js for searching Google Images.

Installation

$ npm install google-ims --save

Usage

Note: You'll need to set up your own Google Custom Search Engine to search for images.

See Google's page on CSE parameters for more info on the options. Example of using all available current options:

'use strict' // need this for 'let' to work

const googleIms = require('google-ims');

let client = googleIms('CSEID', 'APIKEY');

client.search('new zealand', {
	page: 2, // 10 results per page
	size: 'large', // can be: icon, small, medium, large, xlarge, xxlarge, huge
	safe: 'off', // high, medium, off
	// these next three options don't seem to be working currently
	imgType: 'face', // clipart, face, lineart, news, photo
	colorType: 'color', // color, gray, mono
	domColor: 'black', // black, blue, brown, gray, green, pink, purple, teal, white, yellow
	dateRestrict: 'y[2]', // only show results from the last 2 years, can be d[#], w[#], m[#], y[#] for days, weeks, etc
	fileType: 'png',
	gl: 'NZ', // country code for results, New Zealand in this case, http://www.spoonfork.org/isocodes.html
	googlehost: 'google.co.nz', // google domain to use, in this case New Zealand
	num: 1 // number of results per page, default 10
	
}).then(function (images) {
	images.forEach(function(i, e, a) {
		console.log(images)
	});
});

/* output will look like this:

[ { type: 'image/png',
    width: 620,
    height: 349,
    size: 621748,
    url: 'http://www.stuff.co.nz/content/dam/images/1/b/4/w/i/b/image.related.StuffLandscapeSixteenByNine.620x349.1b5jgj.png/1461229326837.png',
    thumbnail: 
     { url: 'https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcR5jJP-Opup26AynNIJYrcgKYVLFCC3jWwCI_auwCUOopybFPL9_l1VOm6r',
       width: 136,
       height: 77 } } ]

*/

Set up Google Custom Search Engine

You need to sign up for Google Custom Search Engine. Here are the steps you need to do:

1. Create a Google Custom Search Engine

You can do this here: https://cse.google.com/cse.

Do not specify any sites to search but instead use the "Restrict Pages using Schema.org Types" under the "Advanced options". For the most inclusive set, use the Schema: Thing. Make a note of the CSE ID.

2. Enable Image Search

In your search engine settings, enable "Image search":

3. Set up a Google Custom Search Engine API

Register a new app and enable Google Custom Search Engine API here: Google Developers Console. Make a note of the API key.

Tests

$ npm test

License

MIT

Origin

Originally from https://github.com/vdemedes/google-images, but I wanted to add in some functionality that vdemedes didn't want to.