google-place-text-search

A simple Ruby gem to search for places using the Google Places Text Search API. Search by query string, optionally biased by location and radius.

Installation

Add this line to your Gemfile:

gem 'google-place-text-search'

Then run:

bundle install

Usage

searcher = GooglePlaceTextSearch.new

results = searcher.get_response(
  "YOUR_GOOGLE_API_KEY",
  5000,                    # radius in meters
  "48.8584,2.2945",        # location as "lat,lng"
  "restaurants near Eiffel Tower"
)

results["results"].each do |place|
  puts place["name"]
  puts place["formatted_address"]
  puts place["rating"]
end

Parameters

Parameter Type Description
api_key String Your Google Places API key
radius Integer Search radius in meters
location String Center point as "lat,lng"
query String Text query to search for

Returns the parsed JSON response from the Google Places API, including a results array with place details.

Dependencies