Python wrapper for getting weather data from AccuWeather servers.
Project description
accuweather
Python wrapper for getting weather data from AccuWeather servers.
API key
To generate API key go to https://developer.accuweather.com/user/register and after registration create an app.
How to use package
import asyncio
import logging
from accuweather import (
AccuWeather,
ApiError,
InvalidApiKeyError,
InvalidCoordinatesError,
RequestsExceededError,
)
from aiohttp import ClientError, ClientSession
LATITUDE = 52.0677904
LONGITUDE = 19.4795644
LOCATION_KEY = "268068"
API_KEY = "xxxxx"
logging.basicConfig(level=logging.DEBUG)
async def main():
async with ClientSession() as websession:
try:
accuweather = AccuWeather(
API_KEY, websession, latitude=LATITUDE, longitude=LONGITUDE
)
current_conditions = await accuweather.async_get_current_conditions()
forecast = await accuweather.async_get_forecast(metric=True)
except (
ApiError,
InvalidApiKeyError,
InvalidCoordinatesError,
ClientError,
RequestsExceededError,
) as error:
print(f"Error: {error}")
else:
print(f"Location: {accuweather.location_name} ({accuweather.location_key})")
print(f"Requests remaining: {accuweather.requests_remaining}")
print(f"Current: {current_conditions}")
print(f"Forecast: {forecast}")
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
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
accuweather-0.0.8.tar.gz
(5.0 kB
view hashes)
Built Distribution
Close
Hashes for accuweather-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a527864ec32001402b1e66a3cafb32474ea46043206e08c5d9054eff4b7c7ca |
|
MD5 | 1ccd53567fbc05be1f8b17668ece06e4 |
|
BLAKE2b-256 | 49d4be7554c27a49f72fbfcf5e4a668f503f647e3ca7db9806ecd2587b6d6b9f |