I am looking for a Google search API wrapper to be used in Node.js, I have searched around but haven't found something updated and fully baked. Can anyone please recommend something working? Thanks
Use of Module Wrapper Function in NodeJS: It provides some global-looking variables that are specific to the module, such as: The module and exports object that can be used to export values from the module. The variables like __filename and __dirname, that tells us the module's absolute filename and its directory path.
Why aren't you using node client lib for Google APIs? https://github.com/google/google-api-nodejs-client
var googleapis = require('googleapis');
googleapis.discover('customsearch', 'v1').execute(function(err, client) {
// set api key
client.withApiKey('...');
client.search.cse.list({ q: '...' }).execute(console.log);
});
I just used node-google-images and it worked right away in less than 2 minutes:
https://github.com/vdemedes/node-google-images
Just call
npm install google-images
and then
client = require( 'google-images' );
client.search( 'Chicken Teriyaki', function (err, images) {
console.log(images)
});
will return
[ { width: '1920', height: '1280', url: 'http://www.springkitchenrestaurant.com/Chicken_Teriyaki.jpg', writeTo: [Function] }]
(actually, it will return 4 results but stackoverflow prevents me from posting more than 2 links... - you get the gist!)
I'm assuming you are not referring to the deprecated Google Web Search API...
The Google Custom Search API is a RESTful API. This means that you can easily access it without a specialized wrapper.
There are a couple of modules that make this easier. The one I usually use is the request module, which lets you make HTTP requests very simply.
You can use jsearch module. Install with:
npm install jsearch
Usage:
js.google('queryStringYouWant',10,function(response){
console.log(response) // for Google results
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With