Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google search API wrapper for Node.js

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

like image 378
user971956 Avatar asked Apr 18 '12 12:04

user971956


People also ask

What is a NodeJS wrapper?

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.


4 Answers

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);
});
like image 74
Burcu Dogan Avatar answered Oct 17 '22 17:10

Burcu Dogan


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!)

like image 24
Nico Avatar answered Oct 17 '22 17:10

Nico


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.

like image 39
Steve Campbell Avatar answered Oct 17 '22 17:10

Steve Campbell


You can use jsearch module. Install with:

npm install jsearch

Usage:

js.google('queryStringYouWant',10,function(response){
    console.log(response) // for Google results 
})
like image 34
hasan Avatar answered Oct 17 '22 15:10

hasan