Metadata-Version: 2.4
Name: imgw_pib
Version: 1.4.2
Summary: Python wrapper for IMGW-PIB API.
Author: Maciej Bieniek
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/bieniu/imgw-pib
Classifier: Development Status :: 5 - Production/Stable
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Typing :: Typed
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiofiles
Requires-Dist: aiohttp>=3.9.4
Requires-Dist: orjson
Requires-Dist: yarl
Provides-Extra: test
Requires-Dist: aioresponses==0.7.8; extra == "test"
Requires-Dist: coverage==7.9.2; extra == "test"
Requires-Dist: freezegun==1.5.3; extra == "test"
Requires-Dist: mypy==1.16.1; extra == "test"
Requires-Dist: pytest-asyncio==1.0.0; extra == "test"
Requires-Dist: pytest-cov==6.2.1; extra == "test"
Requires-Dist: pytest-error-for-skips==2.0.2; extra == "test"
Requires-Dist: pytest-timeout==2.4.0; extra == "test"
Requires-Dist: pytest==8.4.1; extra == "test"
Requires-Dist: ruff==0.12.3; extra == "test"
Requires-Dist: syrupy==4.9.1; extra == "test"
Requires-Dist: types-aiofiles; extra == "test"
Provides-Extra: dev
Requires-Dist: pre-commit==4.2.0; extra == "dev"
Dynamic: license-file

[![GitHub Release][releases-shield]][releases]
[![PyPI][pypi-releases-shield]][pypi-releases]
[![PyPI - Downloads][pypi-downloads]][pypi-statistics]
[![Buy me a coffee][buy-me-a-coffee-shield]][buy-me-a-coffee]
[![PayPal_Me][paypal-me-shield]][paypal-me]
[![Revolut.Me][revolut-me-shield]][revolut-me]

# imgw-pib

Python async wrapper for IMGW-PIB API.

## Installation

You can install the library with pip:

```
pip install imgw-pib
```

## How to use the library

```python
"""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()
```

## Error handling

The library raises `ApiError` when the IMGW-PIB API returns an error, `ClientError` for network-related errors, and `TimeoutError` when a request times out.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

[releases]: https://github.com/bieniu/imgw-pib/releases
[releases-shield]: https://img.shields.io/github/release/bieniu/imgw-pib.svg?style=popout
[pypi-releases]: https://pypi.org/project/imgw-pib/
[pypi-statistics]: https://pepy.tech/project/imgw-pib
[pypi-releases-shield]: https://img.shields.io/pypi/v/imgw-pib
[pypi-downloads]: https://pepy.tech/badge/imgw-pib/month
[buy-me-a-coffee-shield]: https://img.shields.io/static/v1.svg?label=%20&message=Buy%20me%20a%20coffee&color=6f4e37&logo=buy%20me%20a%20coffee&logoColor=white
[buy-me-a-coffee]: https://www.buymeacoffee.com/QnLdxeaqO
[paypal-me-shield]: https://img.shields.io/static/v1.svg?label=%20&message=PayPal.Me&logo=paypal
[paypal-me]: https://www.paypal.me/bieniu79
[revolut-me-shield]: https://img.shields.io/static/v1.svg?label=%20&message=Revolut&logo=revolut
[revolut-me]: https://revolut.me/maciejbieniek
