This module for Node.js helps searching images using Google Images. It provides just one method, search, simplicity FTW.
$ npm install google-images --save
Note: You'll need to set up your own Google Custom Search Engine to search for images.
const googleImages = require('google-images');
let client = googleImages('CSE ID', 'API KEY');
client.search('Steve Angello')
.then(function (images) {
/*
[{
"url": "http://steveangello.com/boss.jpg",
"type": "image/jpeg",
"width": 1024,
"height": 768,
"size": 102451,
"thumbnail": {
"url": "http://steveangello.com/thumbnail.jpg",
"width": 512,
"height": 512
}
}]
*/
});
// paginate results
client.search('Steve Angello', {
page: 2
});
// search for certain size
client.search('Steve Angello', {
size: 'large'
});
Google deprecated their public Google Images API, so to search for images you need to sign up for Google Custom Search Engine. Here are the steps you need to do:
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.
In your search engine settings, enable "Image search":
Register a new app and enable Google Custom Search Engine API here: Google Developers Console. Make a note of the API key.
$ npm test
MIT © Vadym Demedes