Skip to main content

A minimalist Forecast.io API client.

Project description

Build Status Coverage Status Requirements Status Latest Package Version Download Status

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

Documentation

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


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.4.2.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

requests_forecast-0.4.2-py2.py3-none-any.whl (5.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file requests-forecast-0.4.2.tar.gz.

File metadata

File hashes

Hashes for requests-forecast-0.4.2.tar.gz
Algorithm Hash digest
SHA256 4c29345cb6afc0ae1116c13aab26577c893dd39b40d32dc3a0137193e1b8d497
MD5 94e9d5e86cff320591370e0af0b3b772
BLAKE2b-256 e4bc23bb02968a36f94f5a21162019a2bf9f9d921efc4d1d034fac9aa051f94f

See more details on using hashes here.

File details

Details for the file requests_forecast-0.4.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for requests_forecast-0.4.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 93bc4ccb5101feb72c671ccecb2a0ea425bc6b18573eaa210ade02d618375523
MD5 eaf9250fb23ae7579d32cb07d079a49b
BLAKE2b-256 330e2845495396027eb30bd8ce75efc38880b1593ab0ca214cf5d34c832b22b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page