APIs/Data Structures

Forecasts Part One: Getting data

Using the Dark Sky Forecast API at https://developer.forecast.io/, generate a sentence that describes the weather that day.

Right now it is TEMPERATURE degrees out and SUMMARY. Today will be TEMP_FEELING with a high of HIGH_TEMP and a low of LOW_TEMP. RAIN_WARNING.


In [1]:
import requests

In [2]:
import dateutil.parser
import datetime

In [3]:
response = requests.get('https://api.forecast.io/forecast/4da699cf85f9706ce50848a7e59591b7/40.712784,-74.005941')
data = response.json()

In [4]:
data


Out[4]:
{'currently': {'apparentTemperature': 75.65,
  'cloudCover': 0.22,
  'dewPoint': 58.19,
  'humidity': 0.55,
  'icon': 'clear-day',
  'nearestStormDistance': 0,
  'ozone': 341.09,
  'precipIntensity': 0,
  'precipProbability': 0,
  'pressure': 1018.37,
  'summary': 'Clear',
  'temperature': 75.65,
  'time': 1466807738,
  'visibility': 9.75,
  'windBearing': 129,
  'windSpeed': 7.55},
 'daily': {'data': [{'apparentTemperatureMax': 80.67,
    'apparentTemperatureMaxTime': 1466787600,
    'apparentTemperatureMin': 67.52,
    'apparentTemperatureMinTime': 1466762400,
    'cloudCover': 0.1,
    'dewPoint': 59.12,
    'humidity': 0.63,
    'icon': 'partly-cloudy-day',
    'moonPhase': 0.64,
    'ozone': 342.18,
    'precipIntensity': 0,
    'precipIntensityMax': 0,
    'precipProbability': 0,
    'pressure': 1016.25,
    'summary': 'Partly cloudy in the evening.',
    'sunriseTime': 1466760429,
    'sunsetTime': 1466814744,
    'temperatureMax': 80.56,
    'temperatureMaxTime': 1466787600,
    'temperatureMin': 67.52,
    'temperatureMinTime': 1466762400,
    'time': 1466740800,
    'visibility': 9.46,
    'windBearing': 89,
    'windSpeed': 3.95},
   {'apparentTemperatureMax': 84.08,
    'apparentTemperatureMaxTime': 1466881200,
    'apparentTemperatureMin': 63.14,
    'apparentTemperatureMinTime': 1466845200,
    'cloudCover': 0.15,
    'dewPoint': 58.47,
    'humidity': 0.62,
    'icon': 'clear-day',
    'moonPhase': 0.68,
    'ozone': 337.09,
    'precipIntensity': 0,
    'precipIntensityMax': 0,
    'precipProbability': 0,
    'pressure': 1021.58,
    'summary': 'Clear throughout the day.',
    'sunriseTime': 1466846848,
    'sunsetTime': 1466901149,
    'temperatureMax': 84.16,
    'temperatureMaxTime': 1466881200,
    'temperatureMin': 63.14,
    'temperatureMinTime': 1466845200,
    'time': 1466827200,
    'visibility': 9.22,
    'windBearing': 74,
    'windSpeed': 5.07},
   {'apparentTemperatureMax': 85.09,
    'apparentTemperatureMaxTime': 1466967600,
    'apparentTemperatureMin': 65.87,
    'apparentTemperatureMinTime': 1466928000,
    'cloudCover': 0.1,
    'dewPoint': 59.04,
    'humidity': 0.61,
    'icon': 'partly-cloudy-night',
    'moonPhase': 0.71,
    'ozone': 314.25,
    'precipIntensity': 0,
    'precipIntensityMax': 0,
    'precipProbability': 0,
    'pressure': 1023.37,
    'summary': 'Partly cloudy overnight.',
    'sunriseTime': 1466933269,
    'sunsetTime': 1466987551,
    'temperatureMax': 84.61,
    'temperatureMaxTime': 1466967600,
    'temperatureMin': 65.87,
    'temperatureMinTime': 1466928000,
    'time': 1466913600,
    'visibility': 10,
    'windBearing': 140,
    'windSpeed': 5.31},
   {'apparentTemperatureMax': 85.74,
    'apparentTemperatureMaxTime': 1467054000,
    'apparentTemperatureMin': 65.97,
    'apparentTemperatureMinTime': 1467021600,
    'cloudCover': 0.49,
    'dewPoint': 62.51,
    'humidity': 0.7,
    'icon': 'partly-cloudy-day',
    'moonPhase': 0.75,
    'ozone': 302.41,
    'precipIntensity': 0,
    'precipIntensityMax': 0,
    'precipProbability': 0,
    'pressure': 1018.57,
    'summary': 'Partly cloudy throughout the day.',
    'sunriseTime': 1467019692,
    'sunsetTime': 1467073952,
    'temperatureMax': 83.23,
    'temperatureMaxTime': 1467054000,
    'temperatureMin': 65.97,
    'temperatureMinTime': 1467021600,
    'time': 1467000000,
    'visibility': 10,
    'windBearing': 157,
    'windSpeed': 8.25},
   {'apparentTemperatureMax': 88.13,
    'apparentTemperatureMaxTime': 1467147600,
    'apparentTemperatureMin': 71.77,
    'apparentTemperatureMinTime': 1467093600,
    'cloudCover': 0.72,
    'dewPoint': 71.15,
    'humidity': 0.87,
    'icon': 'rain',
    'moonPhase': 0.79,
    'ozone': 302.24,
    'precipIntensity': 0.0323,
    'precipIntensityMax': 0.0727,
    'precipIntensityMaxTime': 1467118800,
    'precipProbability': 0.64,
    'precipType': 'rain',
    'pressure': 1012.34,
    'summary': 'Rain throughout the day.',
    'sunriseTime': 1467106116,
    'sunsetTime': 1467160351,
    'temperatureMax': 81.89,
    'temperatureMaxTime': 1467147600,
    'temperatureMin': 71.77,
    'temperatureMinTime': 1467093600,
    'time': 1467086400,
    'windBearing': 171,
    'windSpeed': 8.86},
   {'apparentTemperatureMax': 79.72,
    'apparentTemperatureMaxTime': 1467237600,
    'apparentTemperatureMin': 66.88,
    'apparentTemperatureMinTime': 1467201600,
    'cloudCover': 0,
    'dewPoint': 62.91,
    'humidity': 0.71,
    'icon': 'rain',
    'moonPhase': 0.82,
    'ozone': 322.7,
    'precipIntensity': 0.0039,
    'precipIntensityMax': 0.0091,
    'precipIntensityMaxTime': 1467172800,
    'precipProbability': 0.43,
    'precipType': 'rain',
    'pressure': 1013.63,
    'summary': 'Drizzle in the morning.',
    'sunriseTime': 1467192542,
    'sunsetTime': 1467246747,
    'temperatureMax': 79.72,
    'temperatureMaxTime': 1467237600,
    'temperatureMin': 66.88,
    'temperatureMinTime': 1467201600,
    'time': 1467172800,
    'windBearing': 318,
    'windSpeed': 10.06},
   {'apparentTemperatureMax': 82.75,
    'apparentTemperatureMaxTime': 1467320400,
    'apparentTemperatureMin': 65.24,
    'apparentTemperatureMinTime': 1467284400,
    'cloudCover': 0.3,
    'dewPoint': 58.76,
    'humidity': 0.62,
    'icon': 'partly-cloudy-night',
    'moonPhase': 0.86,
    'ozone': 332.35,
    'precipIntensity': 0,
    'precipIntensityMax': 0,
    'precipProbability': 0,
    'pressure': 1017.98,
    'summary': 'Mostly cloudy starting in the afternoon.',
    'sunriseTime': 1467278970,
    'sunsetTime': 1467333142,
    'temperatureMax': 81.06,
    'temperatureMaxTime': 1467320400,
    'temperatureMin': 65.24,
    'temperatureMinTime': 1467284400,
    'time': 1467259200,
    'windBearing': 260,
    'windSpeed': 4.51},
   {'apparentTemperatureMax': 78.81,
    'apparentTemperatureMaxTime': 1467406800,
    'apparentTemperatureMin': 69.02,
    'apparentTemperatureMinTime': 1467367200,
    'cloudCover': 0.86,
    'dewPoint': 65.06,
    'humidity': 0.73,
    'icon': 'rain',
    'moonPhase': 0.9,
    'ozone': 304.81,
    'precipIntensity': 0.0007,
    'precipIntensityMax': 0.0027,
    'precipIntensityMaxTime': 1467428400,
    'precipProbability': 0.08,
    'precipType': 'rain',
    'pressure': 1018.83,
    'summary': 'Light rain overnight.',
    'sunriseTime': 1467365399,
    'sunsetTime': 1467419535,
    'temperatureMax': 78.81,
    'temperatureMaxTime': 1467406800,
    'temperatureMin': 69.02,
    'temperatureMinTime': 1467367200,
    'time': 1467345600,
    'windBearing': 189,
    'windSpeed': 9.32}],
  'icon': 'rain',
  'summary': 'Light rain on Tuesday and Wednesday, with temperatures peaking at 85°F on Sunday.'},
 'flags': {'darksky-stations': ['KDIX'],
  'isd-stations': ['725033-94728',
   '725060-94728',
   '725060-99999',
   '997271-99999',
   '999999-94706'],
  'lamp-stations': ['KBLM',
   'KCDW',
   'KEWR',
   'KFRG',
   'KHPN',
   'KJFK',
   'KLGA',
   'KMMU',
   'KNYC',
   'KSMQ',
   'KTEB'],
  'madis-stations': ['AU015',
   'BATN6',
   'C1099',
   'C9714',
   'D0486',
   'D3216',
   'D6004',
   'D9152',
   'E0405',
   'E1296',
   'E2876',
   'KNYC',
   'KTEB',
   'NJ12',
   'NJ65',
   'ROBN4'],
  'sources': ['darksky',
   'lamp',
   'gfs',
   'cmc',
   'nam',
   'rap',
   'rtma',
   'sref',
   'fnmoc',
   'isd',
   'nwspa',
   'madis',
   'nearest-precip'],
  'units': 'us'},
 'hourly': {'data': [{'apparentTemperature': 76.14,
    'cloudCover': 0.08,
    'dewPoint': 57.87,
    'humidity': 0.53,
    'icon': 'clear-day',
    'ozone': 340.74,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1018.44,
    'summary': 'Clear',
    'temperature': 76.14,
    'time': 1466805600,
    'visibility': 9.63,
    'windBearing': 138,
    'windSpeed': 7.42},
   {'apparentTemperature': 75.32,
    'cloudCover': 0.32,
    'dewPoint': 58.4,
    'humidity': 0.56,
    'icon': 'partly-cloudy-day',
    'ozone': 341.32,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1018.33,
    'summary': 'Partly Cloudy',
    'temperature': 75.32,
    'time': 1466809200,
    'visibility': 9.84,
    'windBearing': 123,
    'windSpeed': 7.75},
   {'apparentTemperature': 73.2,
    'cloudCover': 0.38,
    'dewPoint': 59.31,
    'humidity': 0.62,
    'icon': 'partly-cloudy-day',
    'ozone': 342.04,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1018.37,
    'summary': 'Partly Cloudy',
    'temperature': 73.2,
    'time': 1466812800,
    'visibility': 9.84,
    'windBearing': 118,
    'windSpeed': 7.77},
   {'apparentTemperature': 71.52,
    'cloudCover': 0.28,
    'dewPoint': 60.13,
    'humidity': 0.67,
    'icon': 'partly-cloudy-night',
    'ozone': 342.97,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1018.75,
    'summary': 'Partly Cloudy',
    'temperature': 71.52,
    'time': 1466816400,
    'visibility': 9.78,
    'windBearing': 111,
    'windSpeed': 7.14},
   {'apparentTemperature': 70.42,
    'cloudCover': 0.21,
    'dewPoint': 60.86,
    'humidity': 0.72,
    'icon': 'clear-night',
    'ozone': 344.02,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1019.29,
    'summary': 'Clear',
    'temperature': 70.42,
    'time': 1466820000,
    'visibility': 9.44,
    'windBearing': 102,
    'windSpeed': 6.01},
   {'apparentTemperature': 69.52,
    'cloudCover': 0.16,
    'dewPoint': 60.99,
    'humidity': 0.74,
    'icon': 'clear-night',
    'ozone': 344.85,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1019.72,
    'summary': 'Clear',
    'temperature': 69.52,
    'time': 1466823600,
    'visibility': 9.27,
    'windBearing': 91,
    'windSpeed': 4.8},
   {'apparentTemperature': 68.58,
    'cloudCover': 0.13,
    'dewPoint': 61.03,
    'humidity': 0.77,
    'icon': 'clear-night',
    'ozone': 345.21,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1019.93,
    'summary': 'Clear',
    'temperature': 68.58,
    'time': 1466827200,
    'visibility': 9.06,
    'windBearing': 76,
    'windSpeed': 5},
   {'apparentTemperature': 67.46,
    'cloudCover': 0.11,
    'dewPoint': 60.93,
    'humidity': 0.8,
    'icon': 'clear-night',
    'ozone': 345.34,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1020.03,
    'summary': 'Clear',
    'temperature': 67.46,
    'time': 1466830800,
    'visibility': 8.95,
    'windBearing': 62,
    'windSpeed': 4.63},
   {'apparentTemperature': 66.62,
    'cloudCover': 0.09,
    'dewPoint': 60.55,
    'humidity': 0.81,
    'icon': 'clear-night',
    'ozone': 345.59,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1020.16,
    'summary': 'Clear',
    'temperature': 66.62,
    'time': 1466834400,
    'visibility': 8.06,
    'windBearing': 46,
    'windSpeed': 5.01},
   {'apparentTemperature': 65.29,
    'cloudCover': 0.09,
    'dewPoint': 60.05,
    'humidity': 0.83,
    'icon': 'clear-night',
    'ozone': 346.35,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1020.36,
    'summary': 'Clear',
    'temperature': 65.29,
    'time': 1466838000,
    'visibility': 7.06,
    'windBearing': 34,
    'windSpeed': 5.58},
   {'apparentTemperature': 64.04,
    'cloudCover': 0.11,
    'dewPoint': 59.33,
    'humidity': 0.85,
    'icon': 'clear-night',
    'ozone': 347.22,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1020.59,
    'summary': 'Clear',
    'temperature': 64.04,
    'time': 1466841600,
    'visibility': 6.09,
    'windBearing': 25,
    'windSpeed': 5.41},
   {'apparentTemperature': 63.14,
    'cloudCover': 0.14,
    'dewPoint': 58.71,
    'humidity': 0.85,
    'icon': 'clear-night',
    'ozone': 347.4,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1020.86,
    'summary': 'Clear',
    'temperature': 63.14,
    'time': 1466845200,
    'visibility': 5.89,
    'windBearing': 19,
    'windSpeed': 4.97},
   {'apparentTemperature': 64.02,
    'cloudCover': 0.15,
    'dewPoint': 59.24,
    'humidity': 0.84,
    'icon': 'clear-day',
    'ozone': 346.38,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1021.19,
    'summary': 'Clear',
    'temperature': 64.02,
    'time': 1466848800,
    'visibility': 6.99,
    'windBearing': 14,
    'windSpeed': 5.03},
   {'apparentTemperature': 65.98,
    'cloudCover': 0.16,
    'dewPoint': 59.22,
    'humidity': 0.79,
    'icon': 'clear-day',
    'ozone': 344.66,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1021.56,
    'summary': 'Clear',
    'temperature': 65.98,
    'time': 1466852400,
    'visibility': 9.18,
    'windBearing': 17,
    'windSpeed': 5.76},
   {'apparentTemperature': 68.36,
    'cloudCover': 0.15,
    'dewPoint': 58.67,
    'humidity': 0.71,
    'icon': 'clear-day',
    'ozone': 342.94,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1021.85,
    'summary': 'Clear',
    'temperature': 68.36,
    'time': 1466856000,
    'visibility': 9.94,
    'windBearing': 22,
    'windSpeed': 5.77},
   {'apparentTemperature': 70.75,
    'cloudCover': 0.14,
    'dewPoint': 57.24,
    'humidity': 0.62,
    'icon': 'clear-day',
    'ozone': 341.4,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1022.01,
    'summary': 'Clear',
    'temperature': 70.75,
    'time': 1466859600,
    'visibility': 10,
    'windBearing': 32,
    'windSpeed': 5.89},
   {'apparentTemperature': 73.58,
    'cloudCover': 0.1,
    'dewPoint': 55.87,
    'humidity': 0.54,
    'icon': 'clear-day',
    'ozone': 339.86,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1022.1,
    'summary': 'Clear',
    'temperature': 73.58,
    'time': 1466863200,
    'visibility': 10,
    'windBearing': 46,
    'windSpeed': 6.62},
   {'apparentTemperature': 76.23,
    'cloudCover': 0.1,
    'dewPoint': 55.34,
    'humidity': 0.48,
    'icon': 'clear-day',
    'ozone': 338.44,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1022.15,
    'summary': 'Clear',
    'temperature': 76.23,
    'time': 1466866800,
    'visibility': 10,
    'windBearing': 55,
    'windSpeed': 7.15},
   {'apparentTemperature': 78.45,
    'cloudCover': 0.09,
    'dewPoint': 56.08,
    'humidity': 0.46,
    'icon': 'clear-day',
    'ozone': 337.28,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1022.2,
    'summary': 'Clear',
    'temperature': 78.45,
    'time': 1466870400,
    'visibility': 10,
    'windBearing': 61,
    'windSpeed': 7.08},
   {'apparentTemperature': 80.96,
    'cloudCover': 0.11,
    'dewPoint': 57.28,
    'humidity': 0.45,
    'icon': 'clear-day',
    'ozone': 336.25,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1022.2,
    'summary': 'Clear',
    'temperature': 80.79,
    'time': 1466874000,
    'visibility': 10,
    'windBearing': 70,
    'windSpeed': 7.04},
   {'apparentTemperature': 82.92,
    'cloudCover': 0.12,
    'dewPoint': 58.53,
    'humidity': 0.43,
    'icon': 'clear-day',
    'ozone': 335.05,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1022.12,
    'summary': 'Clear',
    'temperature': 83.1,
    'time': 1466877600,
    'visibility': 10,
    'windBearing': 80,
    'windSpeed': 7.11},
   {'apparentTemperature': 84.08,
    'cloudCover': 0.15,
    'dewPoint': 59.65,
    'humidity': 0.44,
    'icon': 'clear-day',
    'ozone': 333.67,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1021.86,
    'summary': 'Clear',
    'temperature': 84.16,
    'time': 1466881200,
    'visibility': 10,
    'windBearing': 90,
    'windSpeed': 7.37},
   {'apparentTemperature': 83.01,
    'cloudCover': 0.16,
    'dewPoint': 59.25,
    'humidity': 0.45,
    'icon': 'clear-day',
    'ozone': 332.11,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1021.56,
    'summary': 'Clear',
    'temperature': 83,
    'time': 1466884800,
    'visibility': 10,
    'windBearing': 105,
    'windSpeed': 8.35},
   {'apparentTemperature': 81.51,
    'cloudCover': 0.2,
    'dewPoint': 58.48,
    'humidity': 0.46,
    'icon': 'clear-day',
    'ozone': 330.17,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1021.42,
    'summary': 'Clear',
    'temperature': 81.27,
    'time': 1466888400,
    'visibility': 10,
    'windBearing': 111,
    'windSpeed': 8.77},
   {'apparentTemperature': 78.98,
    'cloudCover': 0.19,
    'dewPoint': 57.57,
    'humidity': 0.48,
    'icon': 'clear-day',
    'ozone': 326.98,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1021.51,
    'summary': 'Clear',
    'temperature': 78.98,
    'time': 1466892000,
    'visibility': 10,
    'windBearing': 115,
    'windSpeed': 8.53},
   {'apparentTemperature': 77.15,
    'cloudCover': 0.16,
    'dewPoint': 57.41,
    'humidity': 0.51,
    'icon': 'clear-day',
    'ozone': 323.41,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1021.74,
    'summary': 'Clear',
    'temperature': 77.15,
    'time': 1466895600,
    'visibility': 10,
    'windBearing': 117,
    'windSpeed': 7.91},
   {'apparentTemperature': 75.37,
    'cloudCover': 0.14,
    'dewPoint': 57.59,
    'humidity': 0.54,
    'icon': 'clear-day',
    'ozone': 321.74,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1022.04,
    'summary': 'Clear',
    'temperature': 75.37,
    'time': 1466899200,
    'visibility': 10,
    'windBearing': 119,
    'windSpeed': 7.21},
   {'apparentTemperature': 73.62,
    'cloudCover': 0.18,
    'dewPoint': 57.93,
    'humidity': 0.58,
    'icon': 'clear-night',
    'ozone': 324.02,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1022.44,
    'summary': 'Clear',
    'temperature': 73.62,
    'time': 1466902800,
    'visibility': 10,
    'windBearing': 121,
    'windSpeed': 6.5},
   {'apparentTemperature': 72.11,
    'cloudCover': 0.23,
    'dewPoint': 58.47,
    'humidity': 0.62,
    'icon': 'clear-night',
    'ozone': 328.2,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1022.89,
    'summary': 'Clear',
    'temperature': 72.11,
    'time': 1466906400,
    'visibility': 10,
    'windBearing': 123,
    'windSpeed': 5.71},
   {'apparentTemperature': 70.41,
    'cloudCover': 0.25,
    'dewPoint': 58.77,
    'humidity': 0.67,
    'icon': 'partly-cloudy-night',
    'ozone': 330.46,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1023.25,
    'summary': 'Partly Cloudy',
    'temperature': 70.41,
    'time': 1466910000,
    'visibility': 10,
    'windBearing': 125,
    'windSpeed': 4.91},
   {'apparentTemperature': 69.43,
    'cloudCover': 0.24,
    'dewPoint': 59.01,
    'humidity': 0.69,
    'icon': 'clear-night',
    'ozone': 328.69,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1023.42,
    'summary': 'Clear',
    'temperature': 69.43,
    'time': 1466913600,
    'visibility': 10,
    'windBearing': 127,
    'windSpeed': 4.08},
   {'apparentTemperature': 68.55,
    'cloudCover': 0.21,
    'dewPoint': 59.11,
    'humidity': 0.72,
    'icon': 'clear-night',
    'ozone': 325,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1023.49,
    'summary': 'Clear',
    'temperature': 68.55,
    'time': 1466917200,
    'visibility': 10,
    'windBearing': 131,
    'windSpeed': 3.35},
   {'apparentTemperature': 67.72,
    'cloudCover': 0.17,
    'dewPoint': 59.05,
    'humidity': 0.74,
    'icon': 'clear-night',
    'ozone': 321.87,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1023.56,
    'summary': 'Clear',
    'temperature': 67.72,
    'time': 1466920800,
    'visibility': 10,
    'windBearing': 135,
    'windSpeed': 2.64},
   {'apparentTemperature': 66.77,
    'cloudCover': 0.13,
    'dewPoint': 58.77,
    'humidity': 0.75,
    'icon': 'clear-night',
    'ozone': 320.23,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1023.66,
    'summary': 'Clear',
    'temperature': 66.77,
    'time': 1466924400,
    'visibility': 10,
    'windBearing': 129,
    'windSpeed': 1.67},
   {'apparentTemperature': 65.87,
    'cloudCover': 0.09,
    'dewPoint': 58.35,
    'humidity': 0.77,
    'icon': 'clear-night',
    'ozone': 319.17,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1023.77,
    'summary': 'Clear',
    'temperature': 65.87,
    'time': 1466928000,
    'visibility': 10,
    'windBearing': 90,
    'windSpeed': 0.96},
   {'apparentTemperature': 66.33,
    'cloudCover': 0.06,
    'dewPoint': 58.71,
    'humidity': 0.76,
    'icon': 'clear-night',
    'ozone': 318.46,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1023.9,
    'summary': 'Clear',
    'temperature': 66.33,
    'time': 1466931600,
    'visibility': 10,
    'windBearing': 51,
    'windSpeed': 1.18},
   {'apparentTemperature': 67.28,
    'cloudCover': 0.06,
    'dewPoint': 58.79,
    'humidity': 0.74,
    'icon': 'clear-day',
    'ozone': 318.23,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1024.1,
    'summary': 'Clear',
    'temperature': 67.28,
    'time': 1466935200,
    'visibility': 10,
    'windBearing': 48,
    'windSpeed': 1.21},
   {'apparentTemperature': 68.45,
    'cloudCover': 0.06,
    'dewPoint': 58.5,
    'humidity': 0.71,
    'icon': 'clear-day',
    'ozone': 318.36,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1024.33,
    'summary': 'Clear',
    'temperature': 68.45,
    'time': 1466938800,
    'visibility': 10,
    'windBearing': 66,
    'windSpeed': 1.02},
   {'apparentTemperature': 69.79,
    'cloudCover': 0.07,
    'dewPoint': 58.03,
    'humidity': 0.66,
    'icon': 'clear-day',
    'ozone': 318.26,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1024.47,
    'summary': 'Clear',
    'temperature': 69.79,
    'time': 1466942400,
    'visibility': 10,
    'windBearing': 99,
    'windSpeed': 1.19},
   {'apparentTemperature': 71.67,
    'cloudCover': 0.07,
    'dewPoint': 57.42,
    'humidity': 0.61,
    'icon': 'clear-day',
    'ozone': 317.68,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1024.44,
    'summary': 'Clear',
    'temperature': 71.67,
    'time': 1466946000,
    'visibility': 10,
    'windBearing': 120,
    'windSpeed': 1.9},
   {'apparentTemperature': 74.14,
    'cloudCover': 0.07,
    'dewPoint': 56.74,
    'humidity': 0.55,
    'icon': 'clear-day',
    'ozone': 316.87,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1024.31,
    'summary': 'Clear',
    'temperature': 74.14,
    'time': 1466949600,
    'visibility': 10,
    'windBearing': 130,
    'windSpeed': 2.96},
   {'apparentTemperature': 76.71,
    'cloudCover': 0.08,
    'dewPoint': 56.58,
    'humidity': 0.5,
    'icon': 'clear-day',
    'ozone': 315.88,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1024.17,
    'summary': 'Clear',
    'temperature': 76.71,
    'time': 1466953200,
    'visibility': 10,
    'windBearing': 135,
    'windSpeed': 4.29},
   {'apparentTemperature': 79.2,
    'cloudCover': 0.09,
    'dewPoint': 57.54,
    'humidity': 0.48,
    'icon': 'clear-day',
    'ozone': 314.69,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1024.05,
    'summary': 'Clear',
    'temperature': 79.2,
    'time': 1466956800,
    'visibility': 10,
    'windBearing': 138,
    'windSpeed': 5.88},
   {'apparentTemperature': 81.96,
    'cloudCover': 0.11,
    'dewPoint': 59.3,
    'humidity': 0.47,
    'icon': 'clear-day',
    'ozone': 313.32,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1023.92,
    'summary': 'Clear',
    'temperature': 81.65,
    'time': 1466960400,
    'visibility': 10,
    'windBearing': 140,
    'windSpeed': 7.42},
   {'apparentTemperature': 83.95,
    'cloudCover': 0.11,
    'dewPoint': 60.88,
    'humidity': 0.46,
    'icon': 'clear-day',
    'ozone': 311.92,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1023.69,
    'summary': 'Clear',
    'temperature': 83.59,
    'time': 1466964000,
    'visibility': 10,
    'windBearing': 140,
    'windSpeed': 8.74},
   {'apparentTemperature': 85.09,
    'cloudCover': 0.1,
    'dewPoint': 61.64,
    'humidity': 0.46,
    'icon': 'clear-day',
    'ozone': 310.39,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1023.3,
    'summary': 'Clear',
    'temperature': 84.61,
    'time': 1466967600,
    'visibility': 10,
    'windBearing': 141,
    'windSpeed': 9.63},
   {'apparentTemperature': 84.26,
    'cloudCover': 0.08,
    'dewPoint': 61.13,
    'humidity': 0.46,
    'icon': 'clear-day',
    'ozone': 308.82,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1022.81,
    'summary': 'Clear',
    'temperature': 83.86,
    'time': 1466971200,
    'visibility': 10,
    'windBearing': 143,
    'windSpeed': 10.34},
   {'apparentTemperature': 82.79,
    'cloudCover': 0.07,
    'dewPoint': 60.5,
    'humidity': 0.48,
    'icon': 'clear-day',
    'ozone': 307.63,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1022.41,
    'summary': 'Clear',
    'temperature': 82.33,
    'time': 1466974800,
    'visibility': 10,
    'windBearing': 143,
    'windSpeed': 10.63},
   {'apparentTemperature': 80.89,
    'cloudCover': 0.07,
    'dewPoint': 60.02,
    'humidity': 0.51,
    'icon': 'clear-day',
    'ozone': 307.16,
    'precipIntensity': 0,
    'precipProbability': 0,
    'pressure': 1022.2,
    'summary': 'Clear',
    'temperature': 80.04,
    'time': 1466978400,
    'visibility': 10,
    'windBearing': 143,
    'windSpeed': 10.39}],
  'icon': 'partly-cloudy-day',
  'summary': 'Partly cloudy later this evening.'},
 'latitude': 40.712784,
 'longitude': -74.005941,
 'minutely': {'data': [{'precipIntensity': 0,
    'precipProbability': 0,
    'time': 1466807700},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466807760},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466807820},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466807880},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466807940},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808000},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808060},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808120},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808180},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808240},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808300},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808360},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808420},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808480},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808540},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808600},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808660},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808720},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808780},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808840},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808900},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466808960},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809020},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809080},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809140},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809200},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809260},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809320},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809380},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809440},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809500},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809560},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809620},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809680},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809740},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809800},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809860},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809920},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466809980},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810040},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810100},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810160},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810220},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810280},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810340},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810400},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810460},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810520},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810580},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810640},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810700},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810760},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810820},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810880},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466810940},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466811000},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466811060},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466811120},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466811180},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466811240},
   {'precipIntensity': 0, 'precipProbability': 0, 'time': 1466811300}],
  'icon': 'clear-day',
  'summary': 'Clear for the hour.'},
 'offset': -4,
 'timezone': 'America/New_York'}

In [5]:
#data.keys()

In [6]:
#data_list = data['daily']['data']

#for i in data_list:
    #print(i)

In [7]:
#data['currently']['temperature']

In [8]:
def temp(my_dict):
    temperature = my_dict['currently']['temperature']
    temper = str(temperature)
    return temper

temp(data)


Out[8]:
'75.65'

In [9]:
def summ(my_dict):
    summary = my_dict['currently']['summary']
    l = summary.lower()
    return l

summ(data)


Out[9]:
'clear'

In [10]:
def high_temp(my_dict):
    TempMax = data['daily']['data']
    for i in TempMax:
        h_temp = str(i['temperatureMax'])
        return h_temp
high_temp(data)


Out[10]:
'80.56'

In [11]:
def temp_feel(my_dict):
    TemMax = data['daily']['data']
    for i in TemMax:
        hi_temp = i['temperatureMax']
        if hi_temp > 80:
            return "high"
        if hi_temp > 70:
            return "moderate"
        if hi_temp > 50:
            return "warm"
        if hi_temp > 30:
            return "cool"
        if hi_temp < 30:
            return "cold"
temp_feel(data)


Out[11]:
'high'

In [12]:
def low_temp(my_dict):
    TempMin = data['daily']['data']
    for i in TempMin:
        l_temp = str(i['temperatureMin'])
        return l_temp
low_temp(data)


Out[12]:
'67.52'

In [13]:
def rain_warning(my_dict):
    data_list = data['daily']['data']

    for i in data_list:
        rain_prob = float(i['precipIntensity'])
        #print(type(rain_prob))
        if rain_prob > 0.002:
            return "Very light rain!"
        if rain_prob > 0.017:
            return "Light rain, you may bring your umbrella"
        if rain_prob > 0.1:
            return "Moderate rain, you need an umbrella!"
        if rain_prob > 0.4:
            return "Heavy rain, don't miss your umbrella"
rain_warning(data)


Out[13]:
'Very light rain!'

In [14]:
def eq_to_sentence(my_dict):
    return "Right now it is " + temp(my_dict) + " degrees out and " + summ(my_dict) + ". Today will be " + temp_feel(my_dict) + " with a high temperature of " + high_temp(my_dict) + " and a low temperature of " + low_temp(my_dict) + "." + rain_warning(my_dict)
statement = eq_to_sentence(data)

In [15]:
type(statement)


Out[15]:
str

In [22]:
import time

In [23]:
now = time.strftime("%B %d, %Y")
now


Out[23]:
'June 24, 2016'

In [18]:
import requests

In [19]:
key = 'key-f5edb244ca7303dc63f079a4cdb97f73'
sandbox = 'sandbox3b984a674a954bcf8c5f2dca397bc3c1.mailgun.org'
recipient = 'radhika.dwaraka@gmail.com'

In [24]:
request_url = 'https://api.mailgun.net/v2/{0}/messages'.format(sandbox)
request = requests.post(request_url, auth=('api', key), data={
    'from': 'radhika.dwaraka@gmail.com',
    'to': recipient,
    'subject': "8AM Weather forecast:" + now,
    'text': statement,
})
print('Status: {0}'.format(request.status_code))
print('Body:   {0}'.format(request.text))


Status: 200
Body:   {
  "id": "<20160624223636.129668.35660.0F9D37A4@sandbox3b984a674a954bcf8c5f2dca397bc3c1.mailgun.org>",
  "message": "Queued. Thank you."
}

In [ ]:
request_url = 'https://api.mailgun.net/v2/{0}/events'.format(sandbox)
request = requests.get(request_url, auth=('api', key), params={'limit': 5})

print('Status: {0}'.format(request.status_code))
print('Body:   {0}'.format(request.text))

In [ ]: