Skip to main content

Python wrapper for IMGW-PIB API.

Project description

GitHub Release PyPI PyPI - Downloads PayPal_Me

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


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)

Uploaded Source

Built Distribution

imgw_pib-0.0.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

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

Hashes for imgw_pib-0.0.1.tar.gz
Algorithm Hash digest
SHA256 cf821e1911b56852b26d9d0ec37b9d1b883a9e20c6e67918a988bbe9c05e5435
MD5 d765eba873815789cd67eae03718ce97
BLAKE2b-256 e280cf08b616717a937db4f462c8b1b08a7e6140bc52a7cc55a615615c7a9d5b

See more details on using hashes here.

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

Hashes for imgw_pib-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f0ee9d99c01fb58652579e84e9a99301fee5141dd604ab769abef60701547b6
MD5 2e9038c8bd51b0a0ca56ea0f12687722
BLAKE2b-256 3f1275830b62590662487cced55dae2ab9606ab710cd6b98e9de8fbf74937592

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page