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
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.
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.
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.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With