googleplaces

Node.js library for the Google Places API

googleplaces.js

A node.js library for the Google Places API

googleplaces.js makes it easy to talk to the Google Places API from your server side Node.js application

Google already maintains a dedicated client side JavaScript library

Yes, fork, hack and send me a PR

get started

$ npm install googleplaces
# set environment variables
export GOOGLE_PLACES_API_KEY = "your key here"
export GOOGLE_PLACES_OUTPUT_FORMAT = "json"

examples

var GooglePlaces = require("googleplaces");
var googlePlaces = new GooglePlaces(process.env.GOOGLE_PLACES_API_KEY, process.env.GOOGLE_PLACES_OUTPUT_FORMAT);
var parameters;

/**
 * Place search - https://developers.google.com/places/documentation/#PlaceSearchRequests
 */
parameters = {
  location:[-33.8670522, 151.1957362],
  types:"doctor"
};
googlePlaces.placeSearch(parameters, function (error, response) {
  if (error) throw error;
  console.log(response.results);
});
var GooglePlaces = require("googleplaces");
var googlePlaces = new GooglePlaces(process.env.GOOGLE_PLACES_API_KEY, process.env.GOOGLE_PLACES_OUTPUT_FORMAT);
var parameters;

/**
 * Place details requests - https://developers.google.com/places/documentation/#PlaceDetails
 */
parameters = {
  location:[-33.8670522, 151.1957362],
  types:"doctor"
};
googlePlaces.placeSearch(parameters, function (error, response) {
  if (error) throw error;
  googlePlaces.placeDetailsRequest({reference:response.results[0].reference}, function (error, response) {
    if (error) throw error;
    console.log(response.result);
  });
});
var GooglePlaces = require("googleplaces");
var googlePlaces = new GooglePlaces(process.env.GOOGLE_PLACES_API_KEY, process.env.GOOGLE_PLACES_OUTPUT_FORMAT);
var parameters;

/**
 * Text search - https://developers.google.com/places/documentation/#TextSearchRequests
 */
parameters = {
  query:"restaurants in dublin"
};
googlePlaces.textSearch(parameters, function (error, response) {
  if (error) throw error;
  console.log(response.results);
});
var GooglePlaces = require("googleplaces");
var googlePlaces = new GooglePlaces(process.env.GOOGLE_PLACES_API_KEY, process.env.GOOGLE_PLACES_OUTPUT_FORMAT);
var parameters;

/**
 * Radar search - https://developers.google.com/places/documentation/#RadarSearchRequests
 */
parameters = {
  query:"restaurants in dublin"
};
googlePlaces.radarSearch(parameters, function (error, response) {
  if (error) throw error;
  console.log(response.results);
});