Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

A Python Wrapper for the Yahoo Weather API.

Project description

Build Status codecov

A Python wrapper for the Yahoo Weather API.

With the API, you can get up-to-date weather information for any location, including 5-day forecast, wind, atmosphere, astronomy conditions, and more. You can lookup weather by woeid, city name or lat/long.

For more information, check out the API documentation.

Install

pip install weather-api

Examples

Lookup WOEID via http://weather.yahoo.com.

from weather import Weather, Unit

weather = Weather(unit=Unit.CELSIUS)

lookup = weather.lookup(560743)
condition = lookup.condition

print(condition.text)

Lookup via location name.

weather = Weather(unit=Unit.CELSIUS)
location = weather.lookup_by_location('dublin')
condition = location.condition
print(condition.text)

Get weather forecasts for the upcoming days.

weather = Weather(unit=Unit.CELSIUS)

forecasts = location.forecast
for forecast in forecasts:
    print(forecast.text)
    print(forecast.date)
    print(forecast.high)
    print(forecast.low)

Lookup via latitude and longitude

weather = Weather(Unit.CELSIUS)
lookup = weather.lookup_by_latlng(53.3494, -6.2601)
condition = lookup.condition
print(condition.text)

For more examples, check the Examples folder

CLI Usage

usage: __main__.py [-h] [--unit [{c,f}]] [--log] [--start [START]]
                   [--end [END]]
                   location

positional arguments:
  location         The location to lookup.

optional arguments:
  -h, --help       show this help message and exit
  --unit [{c,f}]   The unit to be used. Default is Celsius.
  --log            Pass this argument to output logging
  --start [START]  The forecast start
  --end [END]      The forecast end

Example

$ weather dublin --u c

Rate Limits

Use of the Yahoo Weather API should not exceed reasonable request volume. Access is limited to 2,000 signed calls per day.

Project details


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
weather_api-1.0.7-py2.py3-none-any.whl (8.3 kB) Copy SHA256 hash SHA256 Wheel py2.py3
weather-api-1.0.7.tar.gz (6.0 kB) Copy SHA256 hash SHA256 Source None

Supported by

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