'How can I make my Google Places API textsearch query return only a specific zipcode?

I am trying to perform a textsearch using Google's Places API, and I need the query to only return results that are from a specific zipcode.

My current endpoint_URL is as follows:

https://maps.googleapis.com/maps/api/place/textsearch/json?query=grocery+store+in+37216&location=37216&region=us&type=grocery_or_supermarket,supermarket,bakery,food&key=YOUR_API_KEY

I have tried different variations of the query, including putting the zipcode only in the text query, only specifying the zipcode in the location parameter, and specifying both at the same time.

Right now it seems that specifying the zipcode in query=grocery+store+in+37216 yields the best results, but some of the hits still include incorrect zipcodes.

Does anyone have any suggestions or solutions on how to narrow my results down to only one specific zipcode?

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source