ramiromd
ramiromd

Reputation: 2029

Select Google place detail fields

I'm using the Google Places API to get details about certain places.

I would like to be able to limit the number of fields returned by the detail of a place. For example, get the Google Places API to return only the name, phone number and location of a place.

I read this article from the documentation but, it does not talk about it: https://developers.google.com/places/web-service/details?hl=es-419

Any ideas ?

Upvotes: 2

Views: 3374

Answers (1)

xomena
xomena

Reputation: 32198

The ability to define which fields should be available in the response of Places API web service will become effective today, June 11 2018 or within next days.

I can see that you are checking Spanish version of documentation. Usually localized translations of Google Maps documentation are outdated. I would suggest always checking only English version. However, as I can see Google didn't update English version yet. I would expect an updated documentation within a couple of days.

In the meantime you can find explanations regarding fields in the user guide related to the transition to Google Maps Platform.

https://cloud.google.com/maps-platform/user-guide/product-changes/#frequently-asked-questions

According to the user guide,

Places Details requests will be updated to return only the fields that you specify. Currently when you make a Places Details request, the API returns all of the available data associated with the specified place. With this change, the response is limited to only those fields specified using the fields parameter.

The fields correspond to Places Details results, and are divided into three billing categories: Basic, Contact, and Atmosphere. The cost for each request varies depending on which fields are selected;

The Basic category does not result in any additional charge and includes the following fields:

place_id, name, type, address_components, formatted_address, url, utc_offset, permanently_closed, geometry.location, geometry.viewport, photo.photo_reference, icon, types, adr_address, scope, vicinity

The Contact category results in an additional charge and includes the following fields:

opening_hours.weekday_text, opening_hours.open_now, opening_hours.period, website, formatted_phone_number, international_phone_number

The Atmosphere category results in an additional charge and includes the following fields:

price_level, rating, reviews

Based on this documentation you should create the following request

https://maps.googleapis.com/maps/api/place/details/json?placeid=YOUR_PLACE_ID&fields=name,formatted_phone_number,geometry.location&key=YOUR_API_KEY

I've just tried this request, but it looks like Google didn't switch on fields filter yet. I'm getting all fields in the response. I believe it just matter of days to see this functionality in action.

I hope this helps!

Upvotes: 2

Related Questions