Python wrapper for getting weather data from AccuWeather API.
Project description
accuweather
Python wrapper for getting weather data from AccuWeather API.
API key
To generate API key go to https://developer.accuweather.com/user/register and after registration create an app.
How to use package
"""Example of usage."""
import asyncio
import logging
from aiohttp import ClientError, ClientSession
from accuweather import (
AccuWeather,
ApiError,
InvalidApiKeyError,
InvalidCoordinatesError,
RequestsExceededError,
)
LATITUDE = 52.0677904
LONGITUDE = 19.4795644
API_KEY = "xxxxx"
logging.basicConfig(level=logging.DEBUG)
async def main():
"""Run main function."""
async with ClientSession() as websession:
try:
accuweather = AccuWeather(
API_KEY,
websession,
latitude=LATITUDE,
longitude=LONGITUDE,
language="pl",
)
current_conditions = await accuweather.async_get_current_conditions()
forecast_daily = await accuweather.async_get_daily_forecast(
days=5, metric=True
)
forecast_hourly = await accuweather.async_get_hourly_forecast(
hours=12, 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_daily}")
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-4.0.0.tar.gz
(12.2 kB
view details)
Built Distribution
File details
Details for the file accuweather-4.0.0.tar.gz
.
File metadata
- Download URL: accuweather-4.0.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83dba71e4a52991bfeae1f7a89d0f67fee7b9c21a5072dbe9a17a5ab2ea4fd96 |
|
MD5 | 10f66882421856ef35b0d24f04c40b2f |
|
BLAKE2b-256 | 35e10c62cd166a2740dcf4d59bfd56b54e8af1b27ca9d4054326b95a44f8ab07 |
File details
Details for the file accuweather-4.0.0-py3-none-any.whl
.
File metadata
- Download URL: accuweather-4.0.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eab720f872a3d4926384f820726d44c9c98e2325acb79c0d41d8e62dca184cc0 |
|
MD5 | 65ac1d293298ce9c41eacd89126fc2cf |
|
BLAKE2b-256 | 7ed66477ec3bf68d231d2883c89c077cb94db1504efb5eed0c82baf7eeb34309 |