Python wrapper for IMGW-PIB API.
Project description
imgw-pib
Python async wrapper for IMGW-PIB API.
How to use package
"""Example of usage IMGW-PIB."""
import asyncio
import logging
from aiohttp import ClientError, ClientSession
from imgw_pib import ApiError, ImgwPib
logging.basicConfig(level=logging.DEBUG)
WEATHER_STATION_ID = "12200"
HYDROLOGICAL_STATION_ID = "154190050"
async def main() -> None:
"""Run main function."""
async with ClientSession() as websession:
try:
imgwpib = await ImgwPib.create(
websession,
weather_station_id=WEATHER_STATION_ID,
hydrological_station_id=HYDROLOGICAL_STATION_ID,
)
weather_data = await imgwpib.get_weather_data()
hydrological_data = await imgwpib.get_hydrological_data()
except ApiError as error:
print(f"API Error: {error.status}")
except ClientError as error:
print(f"ClientError: {error}")
except TimeoutError as error:
print(f"TimeoutError: {error}")
else:
print(f"Weather stations: {imgwpib.weather_stations}")
print(f"Weather data: {weather_data}")
print(f"Hydrological stations: {imgwpib.hydrological_stations}")
print(f"Hydrological data: {hydrological_data}")
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
imgw_pib-0.0.1.tar.gz
(10.2 kB
view details)
Built Distribution
File details
Details for the file imgw_pib-0.0.1.tar.gz
.
File metadata
- Download URL: imgw_pib-0.0.1.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf821e1911b56852b26d9d0ec37b9d1b883a9e20c6e67918a988bbe9c05e5435 |
|
MD5 | d765eba873815789cd67eae03718ce97 |
|
BLAKE2b-256 | e280cf08b616717a937db4f462c8b1b08a7e6140bc52a7cc55a615615c7a9d5b |
File details
Details for the file imgw_pib-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: imgw_pib-0.0.1-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f0ee9d99c01fb58652579e84e9a99301fee5141dd604ab769abef60701547b6 |
|
MD5 | 2e9038c8bd51b0a0ca56ea0f12687722 |
|
BLAKE2b-256 | 3f1275830b62590662487cced55dae2ab9606ab710cd6b98e9de8fbf74937592 |