Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Wrapper for Forecast API

Project description

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

Installation:

pip install aioforecast

Usage:

from aioforecast import Forecast
client = Forecast(API_KEY)
data = await client.call(LATITUDE, 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="http://some.proxy.com")
timeout = 60
client = Forecast(API_KEY, connector=proxy, timeout=timeout)
data = await client.call(LATITUDE, 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')

Project details


Release history Release notifications

This version
History Node

0.0.1a2

History Node

0.0.1a1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
aioforecast-0.0.1a2-py2.py3-none-any.whl (5.4 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Jul 10, 2016
aioforecast-0.0.1a2.tar.gz (19.4 kB) Copy SHA256 hash SHA256 Source None Jul 10, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page