Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify fields returned by Google Places API call

Google places response contains a lot of data. Most of which I don't need. Is there a way to specify which fields I want to receive?

Thanks in advance

like image 974
user3002996 Avatar asked Jun 15 '16 08:06

user3002996


People also ask

How do I get data from Google Maps places API?

Go to APIs & Services → Dashboard → Enable APIs & Services at the top and Choose Maps Javascript API from the API Library. This will open up the Map JavaScript API page, and Enable it.

How do I use Google Places Autocomplete API?

Ensure that the API key(s) used for all Place Autocomplete and Place Details requests within a session belong to the same Cloud Console project. Be sure to pass a unique session token for each new session. Using the same token for more than one session will result in each request being billed individually.

How can I get more than 20 results on Google Places API?

The documentation says that the Places API returns up to 20 results. It does not indicate that there is any way to change that limit. So, the short answer seems to be: You can't. Of course, you might be able to sort of fake it by doing queries for several locations, and then merging/de-duplicating the results.

How do I use Google Places API for location analysis and more?

Once you've made an account and are on the Google Cloud platform, you'll want to go to use the drop down navigation in the top left and choose API & Services > Credentials. Once there, you'll want to hit Create Credentials on the top followed by API key.


2 Answers

You can now specify which fields you want returned using the fields parameter

https://developers.google.com/places/web-service/details

Example of returning specific fields from Google Headquarters (from link above):

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4&fields=name,rating,formatted_phone_number&key=YOUR_API_KEY
like image 50
Stu Avatar answered Sep 23 '22 19:09

Stu


From the documentation, No there isn't any parameter in Google Places API that you can define only the fields you need in the response. You can't somehow reduce the data in the response. They come as it is.

The only parameter that can change the size of the response is extensions=review_summary which brings some more fields and not less as you require. I am just mentioning it in case you included it in your call

like image 41
laaposto Avatar answered Sep 21 '22 19:09

laaposto