A minimalist Forecast.io API client.
Project description
For complete docs and API options see: https://developer.forecast.io/docs/v2
Requirements
Python 2.5+
requests 1.2.0+
Installation
To install requests-forecast, simply:
$ pip install requests-forecast
Quickstart
Creating a client
>>> from requests_forecast import Forecast >>> forecast = Forecast(apikey='FORECAST_API_KEY', latitude=38.9717, longitude=-95.235)
Getting the current conditions
>>> current = forecast.get_currently() >>> print current['temperature'] 58.9
Getting minutely conditions
>>> current = forecast.get_minutely() >>> current['summary'] u'Mostly cloudy for the hour.' >>> current['data'][0].keys() [u'precipIntensity', u'time']
Getting hourly conditions
>>> current = forecast.get_hourly() >>> current['temperature'] 59.52 >>> forecast.get_hourly()['summary'] Mostly cloudy until tomorrow afternoon. >>> forecast.get_hourly()['data'][0]['temperature'] >>> 59.52
Getting daily conditions
>>> forecast.get_daily()['summary'] u'Mixed precipitation off-and-on throughout the week; temperatures peaking at 70\xb0 on Sunday.' >>> forecast.get_daily()['data'][0]['temperatureMax'] 63.85 >>> forecast.get_daily()['data'][0]['temperatureMin'] 35.05
Getting alerts
>>> forecast.alerts()
{
"expires": 1366898400,
"uri": "http://alerts.weather.gov/cap/wwacapget.php?x=KS124EFAC89CD0.FreezeWarning.124EFAD6F320KS.TOPNPWTOP.8ab7d76a4db42b9136a1a6849a631097",
"title": "Freeze Warning for Douglas, KS"
}
Example usage
from datetime import datetime
from requests_forecast import Forecast
forecast = Forecast(apikey='YOUR-API-KEY')
data = forecast.get(latitude=38.9717, longitude=-95.235)
>>> forecast.get_currently()['temperature']
58.9
data = forecast.get(latitude=38.9717, longitude=-95.235,
time=datetime(year=2013, month=12, day=29))
>>> forecast.get_currently()['temperature']
58.9
>>> forecast.get_currently()['temperature']
36.75
License
New BSD
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
requests-forecast-0.2.0.tar.gz
(18.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file requests-forecast-0.2.0.tar.gz.
File metadata
- Download URL: requests-forecast-0.2.0.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77fc6c53d8a74250de456299d1b18f13de8da97a7977241ede7dc11d623c08aa
|
|
| MD5 |
2357dadf28b5e97ca466d205e871c652
|
|
| BLAKE2b-256 |
26943b886d984e3990ea8b419f31bdc5a012b49a25baa9a93f2b23ab74cdcd73
|
File details
Details for the file requests_forecast-0.2.0-py2.py3-none-any.whl.
File metadata
- Download URL: requests_forecast-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
360c0d0aff44968fbef99da744e657cacd03eabf9f0aac1b955cf45862ed5be4
|
|
| MD5 |
f54167f7e46c38e5ff554efce4fd5835
|
|
| BLAKE2b-256 |
fc0c00f56dfd3246da7bd6ec713414e1ef43aa873d20c0c5a7ec2fd7a4806222
|