## NearbyPlaces API {docsify-ignore}

<div style="max-width:600px;">

The Nearby Places API is a web service that returns suggestions for nearby places of the particular type in response to an HTTP request. The request can contain a type (required), geographical coordinates (required) for which the address is to be computed, a radius (optional) within which to look for results. 

The Nearby Places API is designed with UI elements, such as places categories list like schools, hospitals etc. in mind.   

A sample Nearby Places HTTP request has the following form:
</div>

<pre><code class="language-sh">https://api.baato.io/api/v1/search/nearby?type=school&lat=27.71765&lon=85.32691&key=YOUR_BAATO_ACCESS_TOKEN&limit=20</code></pre>



<div style="max-width:600px; margin-top:30px; ">


#### Required Parameters

- `key` — *STRING* — your baato.io access token. 
- `type` — *STRING* — The type or category of results that the request should return. For example: hospital, cafe etc.
- `lat` and `lon` — *DOUBLE* — latitude and longitude coordinates around which to retrieve place information.  


The `type` field supports almost all feature types available in [OpenStreetMap](https://wiki.openstreetmap.org/wiki/Map_features). However few features types/tags have been merged to get better results. For example, if you send `type=eat` as the query parameter, it returns combined results for "cafe, restaurant and bakery". However, if you require the results just for "cafe", you can simply send `type=cafe` as the query parameters in the API request.

Here is the list for merged feature types:
- `eat` returns results for `cafe, restaurant, bakery`
- `grocery`
returns results for `department_store, supermarket`
- `tourism`
returns results for `attraction, artwork, museum,park`
- `transport`
returns results for `bus_stop, bus_station`
- `parking` returns results for `parking, bicycle_parking, underground, multi-storey, parking_space, car_parking`
- `shopping`
returns results for `jewelry, sports, gift ,mall,department_store,hardware,kitchen, furniture`
- `children`
returns results for `swimming_pool, playground, recreation_ground, park, water_park, disneyland`
- `night_life`
returns results for `pub, bar, nightclub`
- `entertainment` returns results for `cinema, theatre, casino, nightclub`
- `clinic`
returns results for `clinic, dentist, veterinary, herbalist, ayurvedic`
- `workshop`
returns results for `metal, bicycle, aluminium, car_repair, tyres, car_parts`

> Apart from these, to fetch other OSM feature types like toilets, post_office etc. you can get further information on supported types from [here](https://wiki.openstreetmap.org/wiki/Map_features).

#### Optional Parameters

- `radius` — *INTEGER* —  radius, in kilometers from the specified lat/lon pair within which to look for results. Only integer values supported. By default the value is set to `10`.
- `limit` — *INTEGER* — The number of results that the request should return. By default the value is set to `5`.

#### Filter Parameters

- `sortBy` — *BOOLEAN* —  Sorts the results in ascending order by their distance from the specified location. The nearest one from the provided location is at the top.
- `isOpen` — *BOOLEAN* — Returns only those places that are open for business at the time the query is sent. Places that do not specify opening hours in the Baato places database will not be returned if you include this parameter in your query.

#### Response

The response is a JSON object of the following form:

</div>

<pre><code class="language-js">{
    "timestamp": "Thu May 14 07:35:16 NPT 2020",
    "status": 200,
    "message": "Success",
    "data": [
        {
            "placeId": 274918,
            "osmId": 4027146021,
            "name": "Parkland Hospital",
            "address": "Amar Singh Chowk, Pokhara Metropolitan, Kaski, Nepal",
            "type": "hospital",
            "centroid": {
                "lat": 28.204451249999998,
                "lon": 84.00134361230909
            },
            "tags": [
                "phone|061-431830/ 431930",
                "opening_hours|24/7",
                "email|parklandhospital@gmail.com",
                "amenity|hospital"
            ],
            "geometry": {
                "coordinates": [
                    [
                        [
                            84.0012308,
                            28.2046362
                        ],
                        [
                            84.0012952,
                            28.2042237
                        ],
                        [
                            84.0014963,
                            28.2042421
                        ],
                        [
                            84.0014939,
                            28.2043442
                        ],
                        [
                            84.0014351,
                            28.2043468
                        ],
                        [
                            84.00142,
                            28.2045557
                        ],
                        [
                            84.0012308,
                            28.2046362
                        ]
                    ]
                ],
                "type": "Polygon"
            },
            "score": 0.4886951,
            "radialDistanceInKm": 140.99,
            "open": true
        }
    ]
}</code></pre>

