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.5.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

imgw_pib-0.0.5-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file imgw_pib-0.0.5.tar.gz.

File metadata

  • Download URL: imgw_pib-0.0.5.tar.gz
  • Upload date:
  • Size: 11.4 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.5.tar.gz
Algorithm Hash digest
SHA256 719e08afe5d85a2f12a802ce6452e2638ad613768db3d2c62ade22c158dc2e78
MD5 17ddcb71b4dd22c5eba9572aad510ece
BLAKE2b-256 a1eda3fc1ccc3ed3194f70fb46185130d65b44ed58f27a351cfe55068c6b8bb9

See more details on using hashes here.

File details

Details for the file imgw_pib-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: imgw_pib-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 10.6 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e88cfaad630f44cf99b0977ac296d59ee950f999a57c78cf21cb124b6e315764
MD5 807a5d66f6ad9aebb59f58ad6f34251d
BLAKE2b-256 fd3369c8992c6fb7a9e1354331c6d471580ba9dc2e73518d1ca9efb7eb00882c

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