Python wrapper for getting weather data from AccuWeather servers.
Project description
accuweather
Python wrapper for getting weather data from AccuWeather servers for Limited Trial package.
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 aiohttp import ClientError, ClientSession
from accuweather import (
AccuWeather,
ApiError,
InvalidApiKeyError,
InvalidCoordinatesError,
RequestsExceededError,
)
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)
forecast_hourly = await accuweather.async_get_forecast_hourly(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}")
print(f"Forecast hourly: {forecast_hourly}")
loop = asyncio.new_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.5.0.tar.gz
(9.6 kB
view hashes)
Built Distribution
Close
Hashes for accuweather-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d883d941d4c6bfb24675ba6e3e48996f700046f5c39c350fafe580c086a083d1 |
|
MD5 | 8d5dc89dda59bab591202f83a5229238 |
|
BLAKE2b-256 | 6ef4ec5a4a3b6096793ea6134e08d20cfefca5e34710eabca9f5a9366b661119 |