Subnet Toolsand other network tips

Python framework for api.darksky.net

I wanted to use darksky.net as a quick source for weather forecast data so put together a simple class to get at the properties I needed. As my needs changed I decided to implement the whole (very simple) api. You’ll need an api key but that’s about it.

Here’s a few things you can do with it:

import darksky
#import time

#next_hour = int(time.time()+3600)
latitude = “51.5026959”
longitude = “-0.1508741”
apikey = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”

list_exclude = [“minutely”, “hourly”, “daily”, “flags”,”alerts”]
forecast = darksky.Forecast(apikey)
forecast.set(units=”uk2″)
forecast.set(exclude = list_exclude)
#forecast.set(time = next_hour)

now = forecast.get(latitude,longitude)
print(‘Weather Summary: {summary}’.format(**now[‘currently’]))
print(‘Temperature: {temperature}’.format(**now[‘currently’]))
print(‘Feels like: {apparentTemperature}’.format(**now[‘currently’]))
print(‘Humidity: {humidity}’.format(**now[‘currently’]))

Comments are currently closed.