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.1.0.tar.gz (22.9 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.1.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for vigieaupy-1.1.0.tar.gz
Algorithm Hash digest
SHA256 5f33bd82b5ebce135302c2ec42cd752f6cacf663d9f533a063c03690348470b0
MD5 dca1c258bbfc74dac1c5ccb553d06022
BLAKE2b-256 e7a086c97331e01e2c7771ed731924b3a724a44c99fb43c59e95e9dde506998f

See more details on using hashes here.

Provenance

The following attestation bundles were made for vigieaupy-1.1.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: vigieaupy-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee43dd88d018773ae962e6b2e2b9bf4db97c90363153e4bdd2c785e1b73e137e
MD5 82ad20b134a00e3e6d1277ca9a81f526
BLAKE2b-256 c762a546b9b5ff1d80eaa01261368aaad7e0bad3aacabbfe79965b83314b462b

See more details on using hashes here.

Provenance

The following attestation bundles were made for vigieaupy-1.1.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