In [1]:
import requests
#apikey='4230d91e7452245b2479aec2fc16870d'
In [8]:
# SEOUL = '37.532600,127.024612'
response = requests.get("https://api.forecast.io/forecast/4230d91e7452245b2479aec2fc16870d/37.532600,127.024612")
data = response.json()
In [10]:
data.keys()
Out[10]:
In [11]:
data['timezone']
Out[11]:
In [13]:
# Wind speed
data['currently']['windSpeed']
Out[13]:
In [15]:
# How much warmer does it feel than it actually is
data['currently']['apparentTemperature']-data['currently']['temperature']
Out[15]:
In [44]:
daily = data['daily']['data']
print (daily[0]['moonPhase'])
In [45]:
daily[0]['temperatureMax']-daily[0]['temperatureMin']
Out[45]:
In [51]:
for temmax in daily:
print (temmax['temperatureMax'])
if temmax['temperatureMax'] <80:
print ("Oh, it's cold")
else:
print("Oh, it's warm")
In [52]:
# Miami, Florida = 25.787676,-80.224145
response = requests.get("https://api.forecast.io/forecast/4230d91e7452245b2479aec2fc16870d/25.787676,-80.224145")
data = response.json()
In [53]:
data['timezone']
Out[53]:
In [61]:
hourly = data['hourly']['data']
for weather in hourly:
if weather['cloudCover'] > 0.5:
print (weather['temperature'],"and cloudy")
else:
print(weather['temperature'])
In [80]:
# 1980-12-25 = '346550400'
# Central Park = '40.785091,-73.968285'
response = requests.get("https://api.forecast.io/forecast/4230d91e7452245b2479aec2fc16870d/40.785091,-73.968285,346550400")
data = response.json()
In [81]:
data['currently']['temperature']
print ("It was", data['currently']['temperature'], "degree in Central Park on Christmas Day in 1980")
In [84]:
# 1990-12-25 = '662083200'
response = requests.get("https://api.forecast.io/forecast/4230d91e7452245b2479aec2fc16870d/40.785091,-73.968285,662083200")
data = response.json()
In [85]:
print ("It was", data['currently']['temperature'], "degree in Central Park on Christmas Day in 1990")
In [86]:
# 2000-12-25 = '977702400'
response = requests.get("https://api.forecast.io/forecast/4230d91e7452245b2479aec2fc16870d/40.785091,-73.968285,977702400")
data = response.json()
In [87]:
print ("It was", data['currently']['temperature'], "degree in Central Park on Christmas Day in 2000")