Prompt
How do I search for places near a location with an API?
Latest observation
Nov 3, 2026
OpenAI APIWeb search: off
To search for places near a location with an API, you generally use a Nearby Search or Places Search endpoint from a maps/places provider.
Common approach
-
Get coordinates for your target location
- Either from user input directly (
lat,lng) - Or by geocoding an address/place name first
- Either from user input directly (
-
Call a places endpoint with:
- the coordinates
- a search radius
- optional filters like type/category, keyword, open now, etc.
-
Parse results
- name
- address
- distance
- rating
- place ID / coordinates
Example: Google Places API
If you use Google Places, the nearby search typically looks like:
GET https://maps.googleapis.com/maps/api/place/nearbysearch/json
?location=37.7749,-122.4194
&radius=1500
&type=restaurant
&key=YOUR_API_KEY
Important parameters
location: center point aslat,lngradius: search distance in meterstype: optional category likerestaurant,cafe,hospitalkeyword: optional text querykey: your API key
Example response fields
results[]namevicinitygeometry.locationratingplace_id
Example: OpenStreetMap / Overpass API
For open data, you can use Overpass API:
POST https://overpass-api.de/api/interpreter
Query example:
[out:json];
node(around:1500,37.7749,-122.4194)[amenity=restaurant];
out;
This finds restaurants within 1500 meters of the given coordinates.
If you only have an address
You usually do:
- Geocode address → coordinates
- Nearby search using those coordinates
Example flow:
"1600 Amphitheatre Parkway, Mountain View"- geocode to
37.422, -122.084 - search nearby cafes within 1000m
Best practices
- Use pagination if the API returns many results
- Be aware of rate limits
- Handle no results and API errors
- Use a reasonable radius, because very large radii can return noisy results
- If you need precise “nearby” ranking, compute distance client-side using returned coordinates
If you want, I can give you:
- a Python example
- a JavaScript example
- a Google Maps API example
- an OpenStreetMap/Overpass example
Just tell me which API or language you’re using.