skip to navigation
skip to content

aioforecast 0.0.1a2

Wrapper for Forecast API

Wrapper for Forecast API build on top of async/await syntaxe and aiohttp.


pip install aioforecast


from aioforecast import Forecast
client = Forecast(API_KEY)
data = await, LONGITUDE, TIME)

TCPConnector and 15s timeout are default and can be used as-is in a classic service. But this library can also be used in a constrained infrastructure, like a connected device (IOT). For this purpose, client can be tuned at instantiation time.

For example, your device needs to talk thru a proxy which may be very slow to responde:

from aioforecast import Forecast
from aiohttp import ProxyConnector
proxy = ProxyConnector(proxy="")
timeout = 60
client = Forecast(API_KEY, connector=proxy, timeout=timeout)
data = await, LONGITUDE, TIME)

The object returned is a mapping, with an additionnal headers property that expose response headers. For example:

print('temperature is %s' % data['currently']['temperature'])
if int(data.headers['X-Forecast-Api-Calls']) <= 1000:
    print('still free')
File Type Py Version Uploaded on Size
aioforecast-0.0.1a2-py2.py3-none-any.whl (md5) Python Wheel py2.py3 2016-07-10 5KB
aioforecast-0.0.1a2.tar.gz (md5) Source 2016-07-10 18KB