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/subscriptions 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-5.0.0.tar.gz
(12.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file accuweather-5.0.0.tar.gz.
File metadata
- Download URL: accuweather-5.0.0.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
314c4a1003a8d98afc1086721e2fa56dd2ba0b8c5f1143a1240e0c1b8962d1bf
|
|
| MD5 |
bd94a0ec30f9b5ebf72066efa80913a5
|
|
| BLAKE2b-256 |
fbb12e2a2a22d3b0e76cf64f3b1f778938fbff743b58c7def0d2a766f8a856ca
|
File details
Details for the file accuweather-5.0.0-py3-none-any.whl.
File metadata
- Download URL: accuweather-5.0.0-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9367443ca2564c83b65f159dfed4f182f0cc56c6683562eca0527068d48c9bb7
|
|
| MD5 |
8b817b5b19a754f6d2b0f19624eaa8b0
|
|
| BLAKE2b-256 |
492e83a5ed3b323ccf063927ae17363799b764daec36f30f4c34cda1230428ec
|