Skip to main content

Fetch data from VigiEau fr

Project description

VigiEauPy

Asynchronous Python client for the VigiEau API, the official French service for monitoring water use restrictions during drought periods.

Installation

pip install vigieaupy

Requirements

Usage

import asyncio
from vigieaupy import Consommateur, Source, VigiEau, VigiEauException

async def main():
    api = VigiEau()

    try:
        # Search for a commune by name or postal code
        communes = await api.async_get_cog(name="Nantes")
        # or: communes = await api.async_get_cog(codeZip=44000)

        # Fetch active water restrictions
        restrictions = await api.async_get_data(
            codeInsee=communes[0]["code"],
            source=Source.AEP,
            consommateur=Consommateur.particulier,
        )
        for restriction in restrictions:
            print(restriction)

    except VigiEauException as err:
        print(f"Error: {err}")
    finally:
        await api.async_close()

asyncio.run(main())

API

VigiEau(session=None, timeout=120)

Main client class. Optionally accepts an existing aiohttp.ClientSession and a timeout in seconds.

async_get_cog(codeZip=None, name=None)

Search for communes using the French government API (geo.api.gouv.fr).

Parameter Type Description
codeZip int 5-digit postal code
name str Commune name (3 characters minimum)

Returns a list of matching communes.

async_get_data(codeInsee, source=None, consommateur=None)

Fetch active water restrictions for a commune.

Parameter Type Description
codeInsee str INSEE code of the commune
source Source Water resource type (optional)
consommateur Consommateur Consumer profile (optional)

Enum Source

Value Description
Source.AEP Tap water
Source.SUP Rivers and streams
Source.SOU Groundwater (wells or boreholes)

Enum Consommateur

Value Description
Consommateur.particulier Individual
Consommateur.exploitation Agricultural operation
Consommateur.entreprise Professional
Consommateur.collectivite Local authority

Exceptions

Exception Description
VigiEauException Base client exception
HttpRequestError API communication error
TimeoutExceededError Request timed out
RequestException HTTP error returned by the API

License

GPL-3.0-or-later — see the LICENSE file.

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

vigieaupy-1.2.0.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vigieaupy-1.2.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file vigieaupy-1.2.0.tar.gz.

File metadata

  • Download URL: vigieaupy-1.2.0.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for vigieaupy-1.2.0.tar.gz
Algorithm Hash digest
SHA256 afddeffb2ccdd14d35d317036c107906d19b374ddc2da9229b9d620f6d25fee1
MD5 2325f566b9160795da785ce1f81bb596
BLAKE2b-256 dae3d981008551826cf8a137135bc6d55df1c3bece97909c68d986d1c7f95994

See more details on using hashes here.

Provenance

The following attestation bundles were made for vigieaupy-1.2.0.tar.gz:

Publisher: python-publish.yml on cyr-ius/vigieaupy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vigieaupy-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: vigieaupy-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for vigieaupy-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a09cc77983fea369eebd516ee9f36912c3ba8fe4364a8c181e691f100d337f8
MD5 ccf57f878fef24bbfb726ef12b4352d0
BLAKE2b-256 39f75fa6eda70c243d3789879f892047eae39e4ea0f39f8a230236b32edc962a

See more details on using hashes here.

Provenance

The following attestation bundles were made for vigieaupy-1.2.0-py3-none-any.whl:

Publisher: python-publish.yml on cyr-ius/vigieaupy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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