Nearby Search (Legacy) lets you search for places within a specified area. You can refine your search request by supplying keywords or specifying the type of place you are searching for.
Nearby Search (Legacy) requests
A Nearby Search (Legacy) request is an HTTP URL of the following form:
https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters
where output can be either of the following values:
json(recommended) indicates output in JavaScript Object Notation (JSON)xmlindicates output as XML
Certain parameters are required to initiate a Nearby Search (Legacy) request. As is
standard in URLs, all parameters are separated using the ampersand
(&) character.
Required parameters
-
location
The point around which to retrieve place information. This must be specified as
latitude,longitude. -
radius
Defines the distance (in meters) within which to return place results. You may bias results to a specified circle by passing a
locationand aradiusparameter. Doing so instructs the Places service to prefer showing results within that circle; results outside of the defined area may still be displayed.The radius will automatically be clamped to a maximum value depending on the type of search and other parameters.
- Autocomplete: 50,000 meters
-
Nearby Search:
- with
keywordorname: 50,000 meters -
without
keywordorname-
Up to 50,000 meters, adjusted dynamically based on area density,
independent of
rankbyparameter. -
When using
rankby=distance, the radius parameter won't be accepted, and will result in anINVALID_REQUEST.
-
Up to 50,000 meters, adjusted dynamically based on area density,
independent of
- with
- Query Autocomplete: 50,000 meters
- Text Search: 50,000 meters
Optional parameters
-
keyword
The text string on which to search, for example: "restaurant" or "123 Main Street". This must be a place name, address, or category of establishments. Any other types of input can generate errors and are not guaranteed to return valid results. The Google Places service will return candidate matches based on this string and order the results based on their perceived relevance.
Explicitly including location information using this parameter may conflict with the location, radius, and rankby parameters, causing unexpected results.
If this parameter is omitted, places with a business_status of CLOSED_TEMPORARILY or CLOSED_PERMANENTLY won't be returned.
-
language
The language in which to return results.
- See the list of supported languages. Google often updates the supported languages, so this list may not be exhaustive.
-
If
languageis not supplied, the API attempts to use the preferred language as specified in theAccept-Languageheader. - The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component.
- If a name is not available in the preferred language, the API uses the closest match.
- The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and tér are synonyms for street in Hungarian.
-
maxprice
Restricts results to only those places within the specified range. Valid values range between 0 (most affordable) to 4 (most expensive), inclusive. The exact amount indicated by a specific value will vary from region to region.
-
minprice
Restricts results to only those places within the specified range. Valid values range between 0 (most affordable) to 4 (most expensive), inclusive. The exact amount indicated by a specific value will vary from region to region.
-
name
Equivalent to
keyword. Values in this field are combined with values in thekeywordfield and passed as part of the same search string. -
opennow
Returns only those places that are open for business at the time the query is sent. Places that don't specify opening hours in the Google Places database won't be returned if you include this parameter in your query.
-
pagetoken
Returns up to 20 results from a previously run search. Setting a
pagetokenparameter executes a search with the same parameters used previously—all parameters other thanpagetokenare ignored. -
rankby
Specifies the order in which results are listed. Possible values are:
-
prominence(default). This option sorts results based on their importance. Ranking will favor prominent places within the set radius over nearby places that match but that are less prominent. Prominence can be affected by a place's ranking in Google's index, global popularity, and other factors. When prominence is specified, theradiusparameter is required. -
distance. This option biases search results in ascending order by their distance from the specified location. Whendistanceis specified, one or more ofkeyword,name, ortypeis required andradiusis disallowed.
-
-
type
Restricts the results to places matching the specified type. You can specify only one type. If you provide more than one type, the API ignores all types following the first entry.
-
type=hospital|pharmacy|doctorbecomestype=hospital type=hospital,pharmacy,doctoris ignored entirely
See the list of supported types.
Note: Adding bothkeywordandtypewith the same value (keyword=cafe&type=cafeorkeyword=parking&type=parking) can yieldZERO_RESULTS. -
Nearby Search (Legacy) example
curl
curl -L -X GET 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522%2C151.1957362&radius=1500&type=restaurant&keyword=cruise&key=YOUR_API_KEY'HTTP
https://maps.googleapis.com/maps/api/place/nearbysearch/json ?keyword=cruise &location=-33.8670522%2C151.1957362 &radius=1500 &type=restaurant &key=YOUR_API_KEY
Note: In this example, you need to replace the key
with your own API key in order for the request to work in your application.
Nearby Search (Legacy) responses
The following example shows a Nearby Search (Legacy) response.
JSON
{ "html_attributions": [], "results": [ { "business_status": "OPERATIONAL", "geometry": { "location": { "lat": -33.8587323, "lng": 151.2100055 }, "viewport": { "northeast": { "lat": -33.85739847010727, "lng": 151.2112436298927 }, "southwest": { "lat": -33.86009812989271, "lng": 151.2085439701072 }, }, }, "icon": "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/bar-71.png", "icon_background_color": "#FF9E67", "icon_mask_base_uri": "https://maps.gstatic.com/mapfiles/place_api/icons/v2/bar_pinlet", "name": "Cruise Bar", "opening_hours": { "open_now": false }, "photos": [ { "height": 608, "html_attributions": [ 'A Google User', ], "photo_reference": "Aap_uECvJIZuXT-uLDYm4DPbrV7gXVPeplbTWUgcOJ6rnfc4bUYCEAwPU_AmXGIaj0PDhWPbmrjQC8hhuXRJQjnA1-iREGEn7I0ZneHg5OP1mDT7lYVpa1hUPoz7cn8iCGBN9MynjOPSUe-UooRrFw2XEXOLgRJ-uKr6tGQUp77CWVocpcoG", "width": 1080, }, ], "place_id": "ChIJi6C1MxquEmsR9-c-3O48ykI", "plus_code": { "compound_code": "46R6+G2 The Rocks, New South Wales", "global_code": "4RRH46R6+G2", }, "price_level": 2, "rating": 4, "reference": "ChIJi6C1MxquEmsR9-c-3O48ykI", "scope": "GOOGLE", "types": ["bar", "restaurant", "food", "point_of_interest", "establishment"], "user_ratings_total": 1269, "vicinity": "Level 1, 2 and 3, Overseas Passenger Terminal, Circular Quay W, The Rocks", }, { "business_status": "OPERATIONAL", "geometry": { "location": { "lat": -33.8675219, "lng": 151.2016502 }, "viewport": { "northeast": { "lat": -33.86614532010728, "lng": 151.2031259298927 }, "southwest": { "lat": -33.86884497989272, "lng": 151.2004262701072 }, }, }, "icon": "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png", "icon_background_color": "#7B9EB0", "icon_mask_base_uri": "https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet", "name": "Sydney Harbour Dinner Cruises", "opening_hours": { "open_now": true }, "photos": [ { "height": 835, "html_attributions": [ 'A Google User', ], "photo_reference": "Aap_uEBVsYnNcrpRixtrlHBztigZh70CwYkNWZzQnqJ39SjeBo_wvgKf-kXc6tgaMLBdQrRKmxmSKjOezoZrv-sHKVbTX0OI48HBqYYVnQiZQ-WGeuQDsLEPwX7LaVPa68nUAxX114Zpqt7bryoO9wL4qXdgEnopbOp5WWLALhKEHoIEH7f7", "width": 1200, }, ], "place_id": "ChIJM1mOVTS6EmsRKaDzrTsgids", "plus_code": { "compound_code": "46J2+XM Sydney, New South Wales", "global_code": "4RRH46J2+XM", }, "rating": 4.8, "reference": "ChIJM1mOVTS6EmsRKaDzrTsgids", "scope": "GOOGLE", "types": [ "tourist_attraction", "travel_agency", "restaurant", "food", "point_of_interest", "establishment", ], "user_ratings_total": 9, "vicinity": "32 The Promenade, Sydney", }, // ... ], "status": "OK", }
XML
<?xml version="1.0" encoding="UTF-8"?> <PlaceSearchResponse> <status>OK</status> <result> <name>Cruise Bar</name> <vicinity>Level 1, 2 and 3, Overseas Passenger Terminal, Circular Quay W, The Rocks</vicinity> <type>bar</type> <type>restaurant</type> <type>food</type> <type>point_of_interest</type> <type>establishment</type> <geometry> <location> <lat>-33.8587323</lat> <lng>151.2100055</lng> </location> <viewport> <southwest> <lat>-33.8600981</lat> <lng>151.2085440</lng> </southwest> <northeast> <lat>-33.8573985</lat> <lng>151.2112436</lng> </northeast> </viewport> </geometry> <rating>4.0</rating> <icon>https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/bar-71.png</icon> <reference>ChIJi6C1MxquEmsR9-c-3O48ykI</reference> <opening_hours> <open_now>false</open_now> </opening_hours> <photo> <photo_reference>Aap_uEALIq4sgBHhIYWWapOH2NV1T2I7YdOiLzEH7z-483I764cId1sZkbzSq-hVYTk1PQeaHuZzlRfA7-ilwJ3QWon4b37ePd-PBwZbOwFZHxhYs0Cs7jRSgMHWfOzGivp6ZFG4iupyz50qS5pBZT1WbA2ufacTq_U21TtgffQD31wKRPQk</photo_reference> <width>1080</width> <height>608</height> <html_attribution><a href="https://maps.google.com/maps/contrib/112582655193348962755">A Google User</a></html_attribution> </photo> <price_level>2</price_level> <user_ratings_total>1269</user_ratings_total> <place_id>ChIJi6C1MxquEmsR9-c-3O48ykI</place_id> <scope>GOOGLE</scope> <plus_code> <global_code>4RRH46R6+G2</global_code> <compound_code>46R6+G2 The Rocks, New South Wales</compound_code> </plus_code> <icon_background_color>#FF9E67</icon_background_color> <business_status>OPERATIONAL</business_status> <icon_mask_base_uri>https://maps.gstatic.com/mapfiles/place_api/icons/v2/bar_pinlet</icon_mask_base_uri> </result> <result> <name>Sydney Harbour Dinner Cruises</name> <vicinity>32 The Promenade, Sydney</vicinity> <type>tourist_attraction</type> <type>restaurant</type> <type>food</type> <type>travel_agency</type> <type>point_of_interest</type> <type>establishment</type> <geometry> <location> <lat>-33.8675219</lat> <lng>151.2016502</lng> </location> <viewport> <southwest> <lat>-33.8688450</lat> <lng>151.2004263</lng> </southwest> <northeast> <lat>-33.8661453</lat> <lng>151.2031259</lng> </northeast> </viewport> </geometry> <rating>4.8</rating> <icon>https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png</icon> <reference>ChIJM1mOVTS6EmsRKaDzrTsgids</reference> <opening_hours> <open_now>true</open_now> </opening_hours> <photo> <photo_reference>Aap_uEB5jH7GXdcozv1Y5HX18syo4f128S58NVUnqBbLJMpWbC39K49wp-wzsLOsUT8QKDaag6ISFL8hl1vVuig4jkc5fMMkWKiqw5PY-ebcWZ5tI3gEXEYGGoG_mDAulaMLudUpSwgBx2_RLnA0SSiugqqQUTYlkGyCZSe8HSyngVczy6XN</photo_reference> <width>1200</width> <height>835</height> <html_attribution><a href="https://maps.google.com/maps/contrib/109764923610545394994">A Google User</a></html_attribution> </photo> <user_ratings_total>9</user_ratings_total> <place_id>ChIJM1mOVTS6EmsRKaDzrTsgids</place_id> <scope>GOOGLE</scope> <plus_code> <global_code>4RRH46J2+XM</global_code> <compound_code>46J2+XM Sydney, New South Wales</compound_code> </plus_code> <icon_background_color>#7B9EB0</icon_background_color> <business_status>OPERATIONAL</business_status> <icon_mask_base_uri>https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet</icon_mask_base_uri> </result> <!-- ... --> </PlaceSearchResponse>
PlacesNearbySearchResponse
| Field | Required | Type | Description |
|---|---|---|---|
|
required | Array<string> |
May contain a set of attributions about this listing which must be displayed to the user (some listings may not have attribution). |
|
required | Array<Place> |
Contains an array of places.
Place Search requests return a subset of the fields that are
returned by Place Details requests. If the field you want is not
returned by Place Search, you can use Place Search to get a
place_id, then use that Place ID to make a Place
Details request.
See Place for more information. |
|
required | PlacesSearchStatus |
Contains the status of the request, and may contain debugging information to help you track down why the request failed. See PlacesSearchStatus for more information. |
|
optional | string |
When the service returns a status code other than
|
|
optional | Array<string> |
When the service returns additional information about the request
specification, there may be an additional
|
|
optional | string |
Contains a token that can be used to return up to 20 additional results. A next_page_token will not be returned if there are no additional results to display. The maximum number of results that can be returned is 60. There is a short delay between when a next_page_token is issued, and when it will become valid. |
PlacesSearchStatus
Status codes returned by service.
OKindicating the API request was successful.-
ZERO_RESULTSindicating that the search was successful but returned no results. This may occur if the search was passed alatlngin a remote location. -
INVALID_REQUESTindicating the API request was malformed, generally due to missing required query parameter (locationorradius). -
OVER_QUERY_LIMITindicating any of the following:- You have exceeded the QPS limits.
- Billing has not been enabled on your account.
- The monthly $200 credit, or a self-imposed usage cap, has been exceeded.
- The provided method of payment is no longer valid (for example, a credit card has expired).
-
REQUEST_DENIEDindicating that your request was denied, generally because:- The request is missing an API key.
- The
keyparameter is invalid.
UNKNOWN_ERRORindicating an unknown error.
Place
Place Search responses return the following subset of the
Place
fields. Not all attributes are available for all place types. To retrieve
fields that Place Search doesn't return, such as
address_components, formatted_phone_number,
reviews, or website, pass the returned
place_id in a
Place Details (Legacy)
request. For field availability and pricing tiers across endpoints, see
Place
Data Fields (Legacy).
| Field | Type | Description |
|---|---|---|
business_status |
string |
Indicates the operational status of the place, if it's a business:
OPERATIONAL, CLOSED_TEMPORARILY, or
CLOSED_PERMANENTLY. Omitted if no status data exists.
|
formatted_address |
string |
The human-readable address of this place. Returned by
Text Search (Legacy) and Find Place (Legacy). Don't parse the formatted
address programmatically; request
address_components
in Place Details (Legacy) instead.
|
geometry |
Geometry
|
Contains the geocoded location with lat and
lng coordinates, and the preferred viewport
with northeast and southwest bounds.
|
icon |
string |
The URL of a suggested icon that you can display when indicating this result on a map. |
icon_background_color
|
string |
The default hexadecimal color code for the place's category. |
icon_mask_base_uri |
string |
The base URL of a recommended icon, without the SVG or PNG file type extension. |
name |
string |
The human-readable name for the returned result. For
establishment results, this value is usually the
canonicalized business name.
|
opening_hours |
PlaceOpeningHours
|
Opening hours information. Place Search endpoints return only the
open_now boolean subfield; request
opening_hours
in Place Details (Legacy) for periods and
weekday_text.
|
permanently_closed |
boolean |
Deprecated: Use business_status to check
the operational status of a business.
|
photos |
Array<PlacePhoto>
|
An array of
PlacePhoto
objects, each containing a photo_reference,
height, width, and
html_attributions. For usage details, see
Place Photos (Legacy).
|
place_id |
string |
A textual identifier that uniquely identifies a place. Pass this ID in
the place_id parameter of a
Place Details (Legacy)
request. See the
place ID
overview.
|
plus_code |
PlusCode
|
An encoded location reference derived from latitude and longitude
coordinates, containing a global_code and an optional
compound_code.
|
price_level |
integer |
The price level of the place on a scale from 0 to
4, from least expensive to most expensive. See
price_level.
|
rating |
number |
The place's rating, from 1.0 to 5.0, based on
aggregated user reviews.
|
reference |
string |
Deprecated: Use place_id instead.
|
scope |
string |
Deprecated: Indicates the scope of the
place_id, which is always GOOGLE. Returned by
Nearby Search (Legacy).
|
types |
Array<string> |
An array of feature types describing the given result. See Place Types (Legacy). |
user_ratings_total |
integer |
The total number of ratings, with or without review text, for this place. |
vicinity |
string |
A simplified address for the place, including the street name, street number, and locality, without the state or province, postal code, or country. Returned by Nearby Search (Legacy). |
Accessing Additional Results
By default, each response returns up to
20 establishment results
per query; however, each search can return as many as 60 results, split
across three pages. If your search will return more than
20, then the search response will include
an additional value — next_page_token. Pass the value of
the next_page_token to the pagetoken parameter of
a new request to see the next set of results.
- If the
next_page_tokenis null, or is not returned, then there are no further results. - Retrying the request with the same
next_page_tokenwill return the next page of results. - Setting
pagetokenwill cause any other parameters to be ignored. - You can request a new page up to two times following the original query.
- Each request, including a request using
next_page_token, counts as a single request against your usage limits and is charged separately. - There is a delay of a few seconds between when a
next_page_tokenis issued, and when it will become valid. Requesting the next page before it is available will return anINVALID_REQUESTresponse. Requests withnext_page_tokenare always charged.
For example, in the query below, we search for restaurants near Darling
Harbour, in Sydney Australia, and rank the results by distance. You can see
that the response contains a next_page_token property.
{
"html_attributions" : [],
"next_page_token" : "CpQCAgEAAFxg8o-eU7_uKn7Yqjana-HQIx1hr5BrT4zBaEko29ANsXtp9mrqN0yrKWhf-y2PUpHRLQb1GT-mtxNcXou8TwkXhi1Jbk-ReY7oulyuvKSQrw1lgJElggGlo0d6indiH1U-tDwquw4tU_UXoQ_sj8OBo8XBUuWjuuFShqmLMP-0W59Vr6CaXdLrF8M3wFR4dUUhSf5UC4QCLaOMVP92lyh0OdtF_m_9Dt7lz-Wniod9zDrHeDsz_by570K3jL1VuDKTl_U1cJ0mzz_zDHGfOUf7VU1kVIs1WnM9SGvnm8YZURLTtMLMWx8-doGUE56Af_VfKjGDYW361OOIj9GmkyCFtaoCmTMIr5kgyeUSnB-IEhDlzujVrV6O9Mt7N4DagR6RGhT3g1viYLS4kO5YindU6dm3GIof1Q",
"results" : [...]
"status" : "OK"
}To see the next set of results you can submit a new query, passing the
result of the next_page_token to the pagetoken
parameter. For example:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?pagetoken=CpQCAgEAAFxg8o-eU7_uKn7Yqjana-HQIx1hr5BrT4zBaEko29ANsXtp9mrqN0yrKWhf-y2PUpHRLQb1GT-mtxNcXou8TwkXhi1Jbk-ReY7oulyuvKSQrw1lgJElggGlo0d6indiH1U-tDwquw4tU_UXoQ_sj8OBo8XBUuWjuuFShqmLMP-0W59Vr6CaXdLrF8M3wFR4dUUhSf5UC4QCLaOMVP92lyh0OdtF_m_9Dt7lz-Wniod9zDrHeDsz_by570K3jL1VuDKTl_U1cJ0mzz_zDHGfOUf7VU1kVIs1WnM9SGvnm8YZURLTtMLMWx8-doGUE56Af_VfKjGDYW361OOIj9GmkyCFtaoCmTMIr5kgyeUSnB-IEhDlzujVrV6O9Mt7N4DagR6RGhT3g1viYLS4kO5YindU6dm3GIof1Q&key=YOUR_API_KEY