End-To-End Example: Today's Weather

This example will input a location and then output today's current weather conditions at that location.

To complete this example we will use the following API's


In [29]:
# Todo list
# input a location eg. Syracuse, ny
# use the google geocode api to get a lat/lng
# use the darksky api and lat/lng to get current weather conditions
# output current weather conditions (temperature and summary (rain, snow, etc...))

In [4]:
import requests

In [5]:
def geocode(location):
    query_string = {'q' : location, 'format': 'json'}
    url='https://nominatim.openstreetmap.org/search' 
    response = requests.get(url, params = query_string)
    if response.ok:
        geodata = response.json()
        return geodata
    else:
        print("Error calling api!!!")
        print(response.text)
        
# Testing with syracuse, NY 
geocode('Syracuse, NY')


Out[5]:
[{'place_id': 234807968,
  'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
  'osm_type': 'relation',
  'osm_id': 174916,
  'boundingbox': ['42.9843709', '43.086102', '-76.2046029', '-76.074084'],
  'lat': '43.0481221',
  'lon': '-76.1474244',
  'display_name': 'Syracuse, Onondaga County, New York, United States of America',
  'class': 'boundary',
  'type': 'administrative',
  'importance': 0.6867762857760726,
  'icon': 'https://nominatim.openstreetmap.org/images/mapicons/poi_boundary_administrative.p.20.png'},
 {'place_id': 70735718,
  'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
  'osm_type': 'node',
  'osm_id': 6241108067,
  'boundingbox': ['43.0718312', '43.0818312', '-76.1744003', '-76.1644003'],
  'lat': '43.0768312',
  'lon': '-76.1694003',
  'display_name': 'Syracuse, NBT Bank Parkway, Lakefront, Syracuse, Onondaga County, New York, 13208, United States of America',
  'class': 'railway',
  'type': 'station',
  'importance': 0.4272524353626238,
  'icon': 'https://nominatim.openstreetmap.org/images/mapicons/transport_train_station2.p.20.png'},
 {'place_id': 39170238,
  'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
  'osm_type': 'node',
  'osm_id': 2997656284,
  'boundingbox': ['43.0770382', '43.0771382', '-76.1700021', '-76.1699021'],
  'lat': '43.0770882',
  'lon': '-76.1699521',
  'display_name': 'Syracuse, Walsh Circle, Lakefront, Syracuse, Onondaga County, New York, 13290, United States of America',
  'class': 'railway',
  'type': 'stop',
  'importance': 0.11100000000000002}]

In [10]:
def getweather(lat,lon):
    key = '67f9d45c32dd086df27f2b7a90370a8e' # sign up for your own key at https://darksky.net/dev 
    query_string = { 'lat' : lat, 'lon': lon, 'appid' : key, 'units' : 'imperial'}
    url='https://api.openweathermap.org/data/2.5/onecall' 
    response = requests.get(url, params=query_string)
    #print (response.url)
    weather = response.json()
    return weather

# Testing with syracuse, NY coordinates
getweather( 43.0481221, -76.1474244 )


https://api.openweathermap.org/data/2.5/onecall?lat=43.0481221&lon=-76.1474244&appid=67f9d45c32dd086df27f2b7a90370a8e&units=imperial
Out[10]:
{'lat': 43.05,
 'lon': -76.15,
 'timezone': 'America/New_York',
 'current': {'dt': 1587996788,
  'sunrise': 1587981787,
  'sunset': 1588032055,
  'temp': 41.22,
  'feels_like': 33.08,
  'pressure': 1018,
  'humidity': 81,
  'dew_point': 35.83,
  'uvi': 5.69,
  'clouds': 90,
  'visibility': 16093,
  'wind_speed': 9.17,
  'wind_deg': 350,
  'weather': [{'id': 500,
    'main': 'Rain',
    'description': 'light rain',
    'icon': '10d'}],
  'rain': {'1h': 0.25}},
 'hourly': [{'dt': 1587996000,
   'temp': 41.22,
   'feels_like': 31.98,
   'pressure': 1018,
   'humidity': 81,
   'dew_point': 35.83,
   'clouds': 90,
   'wind_speed': 11.12,
   'wind_deg': 358,
   'weather': [{'id': 500,
     'main': 'Rain',
     'description': 'light rain',
     'icon': '10d'}],
   'rain': {'1h': 0.29}},
  {'dt': 1587999600,
   'temp': 41.7,
   'feels_like': 32.76,
   'pressure': 1018,
   'humidity': 84,
   'dew_point': 37.24,
   'clouds': 95,
   'wind_speed': 11.03,
   'wind_deg': 356,
   'weather': [{'id': 500,
     'main': 'Rain',
     'description': 'light rain',
     'icon': '10d'}],
   'rain': {'1h': 0.33}},
  {'dt': 1588003200,
   'temp': 42.01,
   'feels_like': 33.46,
   'pressure': 1018,
   'humidity': 86,
   'dew_point': 38.14,
   'clouds': 98,
   'wind_speed': 10.63,
   'wind_deg': 353,
   'weather': [{'id': 500,
     'main': 'Rain',
     'description': 'light rain',
     'icon': '10d'}],
   'rain': {'1h': 0.21}},
  {'dt': 1588006800,
   'temp': 42.22,
   'feels_like': 34.05,
   'pressure': 1018,
   'humidity': 87,
   'dew_point': 38.64,
   'clouds': 99,
   'wind_speed': 10.11,
   'wind_deg': 345,
   'weather': [{'id': 500,
     'main': 'Rain',
     'description': 'light rain',
     'icon': '10d'}],
   'rain': {'1h': 0.12}},
  {'dt': 1588010400,
   'temp': 42.57,
   'feels_like': 34.29,
   'pressure': 1018,
   'humidity': 85,
   'dew_point': 38.39,
   'clouds': 100,
   'wind_speed': 10.22,
   'wind_deg': 338,
   'weather': [{'id': 804,
     'main': 'Clouds',
     'description': 'overcast clouds',
     'icon': '04d'}]},
  {'dt': 1588014000,
   'temp': 43.18,
   'feels_like': 34.54,
   'pressure': 1019,
   'humidity': 83,
   'dew_point': 39.43,
   'clouds': 100,
   'wind_speed': 10.85,
   'wind_deg': 334,
   'weather': [{'id': 804,
     'main': 'Clouds',
     'description': 'overcast clouds',
     'icon': '04d'}]},
  {'dt': 1588017600,
   'temp': 43.34,
   'feels_like': 34.59,
   'pressure': 1019,
   'humidity': 82,
   'dew_point': 39.4,
   'clouds': 100,
   'wind_speed': 10.98,
   'wind_deg': 338,
   'weather': [{'id': 804,
     'main': 'Clouds',
     'description': 'overcast clouds',
     'icon': '04d'}]},
  {'dt': 1588021200,
   'temp': 44.46,
   'feels_like': 36.57,
   'pressure': 1019,
   'humidity': 78,
   'dew_point': 39.16,
   'clouds': 100,
   'wind_speed': 9.4,
   'wind_deg': 346,
   'weather': [{'id': 804,
     'main': 'Clouds',
     'description': 'overcast clouds',
     'icon': '04d'}]},
  {'dt': 1588024800,
   'temp': 45.01,
   'feels_like': 38.17,
   'pressure': 1019,
   'humidity': 76,
   'dew_point': 39.04,
   'clouds': 100,
   'wind_speed': 7.49,
   'wind_deg': 347,
   'weather': [{'id': 804,
     'main': 'Clouds',
     'description': 'overcast clouds',
     'icon': '04d'}]},
  {'dt': 1588028400,
   'temp': 44.83,
   'feels_like': 38.86,
   'pressure': 1019,
   'humidity': 77,
   'dew_point': 39.09,
   'clouds': 100,
   'wind_speed': 6.02,
   'wind_deg': 346,
   'weather': [{'id': 804,
     'main': 'Clouds',
     'description': 'overcast clouds',
     'icon': '04d'}]},
  {'dt': 1588032000,
   'temp': 43.3,
   'feels_like': 38.03,
   'pressure': 1020,
   'humidity': 80,
   'dew_point': 38.79,
   'clouds': 99,
   'wind_speed': 4.61,
   'wind_deg': 332,
   'weather': [{'id': 804,
     'main': 'Clouds',
     'description': 'overcast clouds',
     'icon': '04d'}]},
  {'dt': 1588035600,
   'temp': 41.13,
   'feels_like': 36.59,
   'pressure': 1021,
   'humidity': 84,
   'dew_point': 37.71,
   'clouds': 71,
   'wind_speed': 3.02,
   'wind_deg': 325,
   'weather': [{'id': 803,
     'main': 'Clouds',
     'description': 'broken clouds',
     'icon': '04n'}]},
  {'dt': 1588039200,
   'temp': 39.15,
   'feels_like': 33.96,
   'pressure': 1021,
   'humidity': 86,
   'dew_point': 36.34,
   'clouds': 39,
   'wind_speed': 3.78,
   'wind_deg': 285,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03n'}]},
  {'dt': 1588042800,
   'temp': 37.62,
   'feels_like': 32.29,
   'pressure': 1021,
   'humidity': 87,
   'dew_point': 35.2,
   'clouds': 30,
   'wind_speed': 3.69,
   'wind_deg': 268,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03n'}]},
  {'dt': 1588046400,
   'temp': 36.46,
   'feels_like': 31.6,
   'pressure': 1021,
   'humidity': 87,
   'dew_point': 34.25,
   'clouds': 27,
   'wind_speed': 2.55,
   'wind_deg': 258,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03n'}]},
  {'dt': 1588050000,
   'temp': 35.98,
   'feels_like': 31.41,
   'pressure': 1021,
   'humidity': 87,
   'dew_point': 33.76,
   'clouds': 23,
   'wind_speed': 1.9,
   'wind_deg': 247,
   'weather': [{'id': 801,
     'main': 'Clouds',
     'description': 'few clouds',
     'icon': '02n'}]},
  {'dt': 1588053600,
   'temp': 35.71,
   'feels_like': 30.52,
   'pressure': 1020,
   'humidity': 87,
   'dew_point': 33.48,
   'clouds': 19,
   'wind_speed': 2.91,
   'wind_deg': 243,
   'weather': [{'id': 801,
     'main': 'Clouds',
     'description': 'few clouds',
     'icon': '02n'}]},
  {'dt': 1588057200,
   'temp': 35.31,
   'feels_like': 30.09,
   'pressure': 1020,
   'humidity': 87,
   'dew_point': 33.12,
   'clouds': 37,
   'wind_speed': 2.89,
   'wind_deg': 234,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03n'}]},
  {'dt': 1588060800,
   'temp': 35.24,
   'feels_like': 30.07,
   'pressure': 1020,
   'humidity': 87,
   'dew_point': 32.97,
   'clouds': 54,
   'wind_speed': 2.75,
   'wind_deg': 226,
   'weather': [{'id': 803,
     'main': 'Clouds',
     'description': 'broken clouds',
     'icon': '04n'}]},
  {'dt': 1588064400,
   'temp': 35.2,
   'feels_like': 30.07,
   'pressure': 1020,
   'humidity': 87,
   'dew_point': 32.88,
   'clouds': 57,
   'wind_speed': 2.71,
   'wind_deg': 212,
   'weather': [{'id': 803,
     'main': 'Clouds',
     'description': 'broken clouds',
     'icon': '04n'}]},
  {'dt': 1588068000,
   'temp': 34.77,
   'feels_like': 30.04,
   'pressure': 1021,
   'humidity': 87,
   'dew_point': 32.43,
   'clouds': 58,
   'wind_speed': 1.88,
   'wind_deg': 196,
   'weather': [{'id': 803,
     'main': 'Clouds',
     'description': 'broken clouds',
     'icon': '04n'}]},
  {'dt': 1588071600,
   'temp': 37.33,
   'feels_like': 32.65,
   'pressure': 1021,
   'humidity': 85,
   'dew_point': 34.52,
   'clouds': 56,
   'wind_speed': 2.3,
   'wind_deg': 173,
   'weather': [{'id': 803,
     'main': 'Clouds',
     'description': 'broken clouds',
     'icon': '04d'}]},
  {'dt': 1588075200,
   'temp': 42.04,
   'feels_like': 37.96,
   'pressure': 1020,
   'humidity': 79,
   'dew_point': 37.24,
   'clouds': 49,
   'wind_speed': 2.04,
   'wind_deg': 157,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03d'}]},
  {'dt': 1588078800,
   'temp': 46.62,
   'feels_like': 42.87,
   'pressure': 1020,
   'humidity': 71,
   'dew_point': 39.06,
   'clouds': 0,
   'wind_speed': 1.95,
   'wind_deg': 104,
   'weather': [{'id': 800,
     'main': 'Clear',
     'description': 'clear sky',
     'icon': '01d'}]},
  {'dt': 1588082400,
   'temp': 50.18,
   'feels_like': 46.08,
   'pressure': 1020,
   'humidity': 62,
   'dew_point': 38.98,
   'clouds': 19,
   'wind_speed': 2.57,
   'wind_deg': 86,
   'weather': [{'id': 801,
     'main': 'Clouds',
     'description': 'few clouds',
     'icon': '02d'}]},
  {'dt': 1588086000,
   'temp': 53.26,
   'feels_like': 49.08,
   'pressure': 1020,
   'humidity': 55,
   'dew_point': 38.5,
   'clouds': 13,
   'wind_speed': 2.66,
   'wind_deg': 79,
   'weather': [{'id': 801,
     'main': 'Clouds',
     'description': 'few clouds',
     'icon': '02d'}]},
  {'dt': 1588089600,
   'temp': 56.19,
   'feels_like': 52.12,
   'pressure': 1019,
   'humidity': 49,
   'dew_point': 38.41,
   'clouds': 10,
   'wind_speed': 2.39,
   'wind_deg': 84,
   'weather': [{'id': 800,
     'main': 'Clear',
     'description': 'clear sky',
     'icon': '01d'}]},
  {'dt': 1588093200,
   'temp': 58.5,
   'feels_like': 54.82,
   'pressure': 1019,
   'humidity': 46,
   'dew_point': 38.86,
   'clouds': 8,
   'wind_speed': 1.86,
   'wind_deg': 90,
   'weather': [{'id': 800,
     'main': 'Clear',
     'description': 'clear sky',
     'icon': '01d'}]},
  {'dt': 1588096800,
   'temp': 59.72,
   'feels_like': 56.12,
   'pressure': 1018,
   'humidity': 44,
   'dew_point': 39.02,
   'clouds': 11,
   'wind_speed': 1.7,
   'wind_deg': 103,
   'weather': [{'id': 801,
     'main': 'Clouds',
     'description': 'few clouds',
     'icon': '02d'}]},
  {'dt': 1588100400,
   'temp': 59.43,
   'feels_like': 55.72,
   'pressure': 1018,
   'humidity': 44,
   'dew_point': 38.52,
   'clouds': 44,
   'wind_speed': 1.83,
   'wind_deg': 141,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03d'}]},
  {'dt': 1588104000,
   'temp': 58.93,
   'feels_like': 54.73,
   'pressure': 1017,
   'humidity': 45,
   'dew_point': 38.59,
   'clouds': 50,
   'wind_speed': 2.73,
   'wind_deg': 158,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03d'}]},
  {'dt': 1588107600,
   'temp': 58.42,
   'feels_like': 53.65,
   'pressure': 1017,
   'humidity': 46,
   'dew_point': 39.06,
   'clouds': 43,
   'wind_speed': 3.78,
   'wind_deg': 164,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03d'}]},
  {'dt': 1588111200,
   'temp': 57.65,
   'feels_like': 53.04,
   'pressure': 1018,
   'humidity': 50,
   'dew_point': 40.3,
   'clouds': 36,
   'wind_speed': 3.94,
   'wind_deg': 148,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03d'}]},
  {'dt': 1588114800,
   'temp': 54.95,
   'feels_like': 50.41,
   'pressure': 1018,
   'humidity': 59,
   'dew_point': 41.94,
   'clouds': 29,
   'wind_speed': 4.41,
   'wind_deg': 102,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03d'}]},
  {'dt': 1588118400,
   'temp': 49.87,
   'feels_like': 44.51,
   'pressure': 1019,
   'humidity': 63,
   'dew_point': 38.86,
   'clouds': 24,
   'wind_speed': 4.85,
   'wind_deg': 104,
   'weather': [{'id': 801,
     'main': 'Clouds',
     'description': 'few clouds',
     'icon': '02d'}]},
  {'dt': 1588122000,
   'temp': 47.39,
   'feels_like': 41.74,
   'pressure': 1019,
   'humidity': 66,
   'dew_point': 37.8,
   'clouds': 0,
   'wind_speed': 4.99,
   'wind_deg': 128,
   'weather': [{'id': 800,
     'main': 'Clear',
     'description': 'clear sky',
     'icon': '01n'}]},
  {'dt': 1588125600,
   'temp': 46.02,
   'feels_like': 39.79,
   'pressure': 1020,
   'humidity': 68,
   'dew_point': 37.29,
   'clouds': 8,
   'wind_speed': 5.86,
   'wind_deg': 148,
   'weather': [{'id': 800,
     'main': 'Clear',
     'description': 'clear sky',
     'icon': '01n'}]},
  {'dt': 1588129200,
   'temp': 45.48,
   'feels_like': 39.02,
   'pressure': 1020,
   'humidity': 69,
   'dew_point': 37.22,
   'clouds': 35,
   'wind_speed': 6.22,
   'wind_deg': 159,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03n'}]},
  {'dt': 1588132800,
   'temp': 44.78,
   'feels_like': 38.3,
   'pressure': 1020,
   'humidity': 71,
   'dew_point': 37.29,
   'clouds': 48,
   'wind_speed': 6.26,
   'wind_deg': 147,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03n'}]},
  {'dt': 1588136400,
   'temp': 44.24,
   'feels_like': 37.96,
   'pressure': 1020,
   'humidity': 74,
   'dew_point': 37.69,
   'clouds': 58,
   'wind_speed': 6.06,
   'wind_deg': 127,
   'weather': [{'id': 803,
     'main': 'Clouds',
     'description': 'broken clouds',
     'icon': '04n'}]},
  {'dt': 1588140000,
   'temp': 43.54,
   'feels_like': 36.97,
   'pressure': 1019,
   'humidity': 78,
   'dew_point': 38.21,
   'clouds': 65,
   'wind_speed': 6.78,
   'wind_deg': 118,
   'weather': [{'id': 803,
     'main': 'Clouds',
     'description': 'broken clouds',
     'icon': '04n'}]},
  {'dt': 1588143600,
   'temp': 43.14,
   'feels_like': 36.25,
   'pressure': 1019,
   'humidity': 80,
   'dew_point': 38.41,
   'clouds': 98,
   'wind_speed': 7.45,
   'wind_deg': 112,
   'weather': [{'id': 804,
     'main': 'Clouds',
     'description': 'overcast clouds',
     'icon': '04n'}]},
  {'dt': 1588147200,
   'temp': 43.29,
   'feels_like': 35.49,
   'pressure': 1018,
   'humidity': 80,
   'dew_point': 38.61,
   'clouds': 79,
   'wind_speed': 9.08,
   'wind_deg': 124,
   'weather': [{'id': 803,
     'main': 'Clouds',
     'description': 'broken clouds',
     'icon': '04n'}]},
  {'dt': 1588150800,
   'temp': 43.56,
   'feels_like': 35.46,
   'pressure': 1018,
   'humidity': 78,
   'dew_point': 38.41,
   'clouds': 53,
   'wind_speed': 9.51,
   'wind_deg': 128,
   'weather': [{'id': 803,
     'main': 'Clouds',
     'description': 'broken clouds',
     'icon': '04n'}]},
  {'dt': 1588154400,
   'temp': 43.83,
   'feels_like': 36.01,
   'pressure': 1019,
   'humidity': 76,
   'dew_point': 38.07,
   'clouds': 49,
   'wind_speed': 8.88,
   'wind_deg': 132,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03n'}]},
  {'dt': 1588158000,
   'temp': 45.86,
   'feels_like': 37.29,
   'pressure': 1019,
   'humidity': 73,
   'dew_point': 38.73,
   'clouds': 59,
   'wind_speed': 10.51,
   'wind_deg': 131,
   'weather': [{'id': 803,
     'main': 'Clouds',
     'description': 'broken clouds',
     'icon': '04d'}]},
  {'dt': 1588161600,
   'temp': 47.66,
   'feels_like': 38.25,
   'pressure': 1018,
   'humidity': 71,
   'dew_point': 39.97,
   'clouds': 66,
   'wind_speed': 12.35,
   'wind_deg': 136,
   'weather': [{'id': 803,
     'main': 'Clouds',
     'description': 'broken clouds',
     'icon': '04d'}]},
  {'dt': 1588165200,
   'temp': 49.17,
   'feels_like': 37.99,
   'pressure': 1018,
   'humidity': 71,
   'dew_point': 41.16,
   'clouds': 99,
   'wind_speed': 15.97,
   'wind_deg': 143,
   'weather': [{'id': 804,
     'main': 'Clouds',
     'description': 'overcast clouds',
     'icon': '04d'}]}],
 'daily': [{'dt': 1588006800,
   'sunrise': 1587981787,
   'sunset': 1588032055,
   'temp': {'day': 42.3,
    'min': 35.71,
    'max': 44.24,
    'night': 35.71,
    'eve': 43.29,
    'morn': 41.22},
   'feels_like': {'day': 33.96, 'night': 30.52, 'eve': 38.01, 'morn': 31.75},
   'pressure': 1018,
   'humidity': 85,
   'dew_point': 38.12,
   'wind_speed': 10.22,
   'wind_deg': 338,
   'weather': [{'id': 501,
     'main': 'Rain',
     'description': 'moderate rain',
     'icon': '10d'}],
   'clouds': 98,
   'rain': 3.06,
   'uvi': 5.69},
  {'dt': 1588093200,
   'sunrise': 1588068101,
   'sunset': 1588118525,
   'temp': {'day': 59.72,
    'min': 42.04,
    'max': 59.72,
    'night': 43.54,
    'eve': 49.87,
    'morn': 42.04},
   'feels_like': {'day': 56.12, 'night': 36.97, 'eve': 44.51, 'morn': 37.96},
   'pressure': 1018,
   'humidity': 44,
   'dew_point': 39.02,
   'wind_speed': 1.7,
   'wind_deg': 103,
   'weather': [{'id': 801,
     'main': 'Clouds',
     'description': 'few clouds',
     'icon': '02d'}],
   'clouds': 11,
   'uvi': 6.56},
  {'dt': 1588179600,
   'sunrise': 1588154416,
   'sunset': 1588204995,
   'temp': {'day': 55.44,
    'min': 47.66,
    'max': 56.59,
    'night': 56.59,
    'eve': 54.16,
    'morn': 47.66},
   'feels_like': {'day': 46.76, 'night': 42.94, 'eve': 43.79, 'morn': 38.25},
   'pressure': 1016,
   'humidity': 71,
   'dew_point': 47.39,
   'wind_speed': 13.82,
   'wind_deg': 142,
   'weather': [{'id': 804,
     'main': 'Clouds',
     'description': 'overcast clouds',
     'icon': '04d'}],
   'clouds': 100,
   'uvi': 6.46},
  {'dt': 1588266000,
   'sunrise': 1588240733,
   'sunset': 1588291465,
   'temp': {'day': 57.85,
    'min': 50.85,
    'max': 59.11,
    'night': 50.85,
    'eve': 56.05,
    'morn': 58.42},
   'feels_like': {'day': 53.76, 'night': 46.69, 'eve': 49.77, 'morn': 47.95},
   'pressure': 1004,
   'humidity': 84,
   'dew_point': 54.19,
   'wind_speed': 8.93,
   'wind_deg': 181,
   'weather': [{'id': 501,
     'main': 'Rain',
     'description': 'moderate rain',
     'icon': '10d'}],
   'clouds': 100,
   'rain': 10.96,
   'uvi': 6.05},
  {'dt': 1588352400,
   'sunrise': 1588327051,
   'sunset': 1588377934,
   'temp': {'day': 54.97,
    'min': 46.94,
    'max': 54.97,
    'night': 49.82,
    'eve': 47.35,
    'morn': 46.98},
   'feels_like': {'day': 52.11, 'night': 45.48, 'eve': 41.7, 'morn': 43.32},
   'pressure': 1005,
   'humidity': 68,
   'dew_point': 45.72,
   'wind_speed': 2.86,
   'wind_deg': 321,
   'weather': [{'id': 501,
     'main': 'Rain',
     'description': 'moderate rain',
     'icon': '10d'}],
   'clouds': 100,
   'rain': 4.57,
   'uvi': 6.48},
  {'dt': 1588438800,
   'sunrise': 1588413370,
   'sunset': 1588464404,
   'temp': {'day': 59.95,
    'min': 48.27,
    'max': 59.95,
    'night': 49.51,
    'eve': 52.47,
    'morn': 48.27},
   'feels_like': {'day': 53.35, 'night': 47.1, 'eve': 49.71, 'morn': 42.6},
   'pressure': 1013,
   'humidity': 61,
   'dew_point': 47.52,
   'wind_speed': 10.27,
   'wind_deg': 301,
   'weather': [{'id': 500,
     'main': 'Rain',
     'description': 'light rain',
     'icon': '10d'}],
   'clouds': 100,
   'rain': 0.62,
   'uvi': 7.44},
  {'dt': 1588525200,
   'sunrise': 1588499690,
   'sunset': 1588550873,
   'temp': {'day': 62.67,
    'min': 47.84,
    'max': 63.03,
    'night': 47.84,
    'eve': 55,
    'morn': 50.61},
   'feels_like': {'day': 53.47, 'night': 41.32, 'eve': 50.94, 'morn': 44.26},
   'pressure': 1008,
   'humidity': 51,
   'dew_point': 45.68,
   'wind_speed': 13.98,
   'wind_deg': 304,
   'weather': [{'id': 802,
     'main': 'Clouds',
     'description': 'scattered clouds',
     'icon': '03d'}],
   'clouds': 46,
   'uvi': 7.06},
  {'dt': 1588611600,
   'sunrise': 1588586012,
   'sunset': 1588637342,
   'temp': {'day': 60.31,
    'min': 45.79,
    'max': 60.31,
    'night': 45.79,
    'eve': 50.95,
    'morn': 48.83},
   'feels_like': {'day': 53.67, 'night': 41.9, 'eve': 47.19, 'morn': 39.99},
   'pressure': 1012,
   'humidity': 54,
   'dew_point': 44.56,
   'wind_speed': 9.17,
   'wind_deg': 314,
   'weather': [{'id': 801,
     'main': 'Clouds',
     'description': 'few clouds',
     'icon': '02d'}],
   'clouds': 15,
   'uvi': 7.57}]}

In [11]:
# then test them here to figue out how to extract from the dictionary
geodata = geocode('Syracuse, NY')
lat = geodata[0]['lat']
lon = geodata[0]['lon']
weather = getweather(lat, lon)
weather['current']


https://api.openweathermap.org/data/2.5/onecall?lat=43.0481221&lon=-76.1474244&appid=67f9d45c32dd086df27f2b7a90370a8e&units=imperial
Out[11]:
{'dt': 1587996788,
 'sunrise': 1587981787,
 'sunset': 1588032055,
 'temp': 41.22,
 'feels_like': 33.08,
 'pressure': 1018,
 'humidity': 81,
 'dew_point': 35.83,
 'uvi': 5.69,
 'clouds': 90,
 'visibility': 16093,
 'wind_speed': 9.17,
 'wind_deg': 350,
 'weather': [{'id': 500,
   'main': 'Rain',
   'description': 'light rain',
   'icon': '10d'}],
 'rain': {'1h': 0.25}}

In [14]:
import requests
# Now I can write the entire program...
location = input("Where are you? (eg. Syracuse, NY) : ")
geodata = geocode(location)
lat,lon = geodata[0]['lat'], geodata[0]['lon']
weather = getweather(lat,lon)
current = weather['current']
print(f"Current conditions in {location} are {current['weather'][0]['description']} with a temperature of {current['temp']} degrees.")


Where are you? (eg. Syracuse, NY) : Syracuse, NY
https://api.openweathermap.org/data/2.5/onecall?lat=43.0481221&lon=-76.1474244&appid=67f9d45c32dd086df27f2b7a90370a8e&units=imperial
Current conditions in Syracuse, NY are light rain with a temperature of 41.22 degrees.

In [ ]: