![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
= Google Places
This gem provides a Ruby wrapper around the Google Places API, using HTTParty. At this moment the gem does not support OAuth authentication and will only work with an API key.
== Obtaining an API key
To be able to use this gem, you'll need a Google Places API key. To request an API key, point your browser to https://code.google.com/apis/console and follow the instructions there. You'll find your API key on the API Access tab under Simple API Access.
== Installing the gem
To use this gem, install it with gem install google_places or add it to your Gemfile:
gem 'google_places'
And install it with bundle install
== Usage
=== The spot
Each of the API methods below returns a GooglePlaces::Spot or a collection of those. Each of these objects has these attributes:
=== Retrieving a list of spots
First register a new Client:
@client = GooglePlaces::Client.new(API_KEY)
Then retrieve a list of spots:
@client.spots(-33.8670522, 151.1957362)
Search by a specific type:
@client.spots(-33.8670522, 151.1957362, :types => 'restaurant')
Search by multiple types:
@client.spots(-33.8670522, 151.1957362, :types => ['restaurant','food'])
Search by multiple types but exclude one type:
@client.spots(-33.8670522, 151.1957362, :types => ['restaurant','food'], :exclude => 'cafe')
Search by multiple types but exclude multiple types:
@client.spots(-33.8670522, 151.1957362, :types => ['restaurant','food'], :exclude => ['cafe', 'establishment'])
Search by name:
@client.spots(-33.8670522, 151.1957362, :name => 'italian')
Search by name and type:
@client.spots(-33.8670522, 151.1957362, :name => 'italian', :types => 'restaurant')
Search in a radius (in meters):
@client.spots(-33.8670522, 151.1957362, :radius => 100)
Get results in specific language:
@client.spots(-33.8670522, 151.1957362, :language => 'en')
=== Retrieving spots based on query
@client.spots_by_query('Pizza near Miami Florida')
Search by multiple types and exclude multiple types
@client.spots_by_query('Pizza near Miami Florida', :types => ['restaurant', 'food'], :exclude => ['cafe', 'establishment'])
=== Retrieving a single spot
First register a new Client:
@client = GooglePlaces::Client.new(API_KEY)
Then retrieve the spot:
@client.spot('CmRYAAA...upoTH3g')
=== Retrieving a single photo's url
First register a new Client:
@client = GooglePlaces::Client.new(API_KEY)
Then retrieve the spot:
@spot = @client.spot('CmRYAAA...upoTH3g')
Then request one of the photos url with a max width:
url = @spot.photos[0].fetch_url(800)
=== Places Autocomplete
https://developers.google.com/places/documentation/autocomplete
Note: Autocomplete is often used and better suited on client side (browser/javascript). The Autocomplete API is rate limited, so make sure you check the usage limits before deciding on whether to call the API server/client side.
https://developers.google.com/maps/documentation/business/articles/usage_limits
==== Example usage
Register a new Client:
@client = GooglePlaces::Client.new(API_KEY)
Then request a prediction based on partial match:
@client.predictions_by_input( 'San F', lat: 0.0, lng: 0.0, radius: 20000000, types: 'geocode', language: I18n.locale, )
The response will be an array of predictions.
== Development
You're very welcome to add functionality to this gem. To do so, follow these steps:
Feel free to send me a pull request but please make sure your changes are sufficiently covered by RSpec.
== Important Note
Concerning the reference field, the Google Places API documentation states:
"You can store this token and use it at any time in future to refresh cached data about this Place, but the same token is not guaranteed to be returned for any given Place across different searches."
Please be aware that the reference field in spot details may differ from the reference used to retrieve that spot.
FAQs
Unknown package
We found that rusty_google_places demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.