import requests


def get_nearby_stops(key, base_url, latitude, longitude):

    """Sends request to get the nearest 5 bus stops"""

    print('Finding nearby bus stops')
    params = {
        "key": key,
        "lat": latitude,
        "lon": longitude,
        "count": 5
    }
    r = requests.get(base_url + '/getstopsbylatlon', params=params)
    if r.status_code == 200:
        return r.json()
    else:
        return "Can't find nearby bus stops: Error {0}".format(r.status_code)