{"id":50537019,"url":"https://github.com/pfei/hubeau-data","last_synced_at":"2026-06-12T15:00:52.899Z","repository":{"id":295065900,"uuid":"986843439","full_name":"pfei/hubeau-data","owner":"pfei","description":"Typed Python client for the Hubeau water data APIs — Pydantic models, uv, strict mypy","archived":false,"fork":false,"pushed_at":"2026-06-11T09:35:17.000Z","size":357,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-11T10:24:40.005Z","etag":null,"topics":["api-client","hubeau","mypy","open-data","pydantic","python","uv","water"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pfei.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-20T07:50:10.000Z","updated_at":"2026-06-11T09:35:24.000Z","dependencies_parsed_at":"2025-06-10T17:36:52.391Z","dependency_job_id":null,"html_url":"https://github.com/pfei/hubeau-data","commit_stats":null,"previous_names":["pfei/hubeau-py","pfei/hubeau-data"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pfei/hubeau-data","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfei%2Fhubeau-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfei%2Fhubeau-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfei%2Fhubeau-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfei%2Fhubeau-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pfei","download_url":"https://codeload.github.com/pfei/hubeau-data/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfei%2Fhubeau-data/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34249561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","hubeau","mypy","open-data","pydantic","python","uv","water"],"created_at":"2026-06-03T17:30:18.600Z","updated_at":"2026-06-12T15:00:52.892Z","avatar_url":"https://github.com/pfei.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hubeau-data\n\n[![CI](https://github.com/pfei/hubeau-data/actions/workflows/ci.yml/badge.svg)](https://github.com/pfei/hubeau-data/actions/workflows/ci.yml)\n[![Python Version](https://img.shields.io/badge/python-3.13+-blue.svg)](https://www.python.org/)\n[![Checked with mypy](https://img.shields.io/badge/mypy-strict-green.svg)](https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file)\n[![Linting: ruff](https://img.shields.io/badge/linting-ruff-orange.svg)](https://github.com/astral-sh/ruff)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Package Manager: uv](https://img.shields.io/badge/managed%20by-uv-purple.svg)](https://github.com/astral-sh/uv)\n\nTyped, modern Python client for the [Hub'Eau](https://hubeau.eaufrance.fr/) water data APIs.\n\nHub'Eau exposes 15+ REST APIs for French national water data — but no official typed Python client exists.\nThis library fills that gap: Pydantic v2 models, strict typing, and a clean interface ready for data science workflows.\n\n## Quickstart\n\n```python\nfrom hubeau_data.client import HubeauClient\nfrom hubeau_data.models.hydrometrie import ObservationTrParams\nfrom hubeau_data.models.qualite_rivieres import StationPcParams\n\nclient = HubeauClient()\n\n# Hydrométrie — real-time observations\nparams = ObservationTrParams(code_station=[\"Y120201001\"], size=3)\nobservations = client.hydrometrie.get_observations_tr(params=params)\nprint(observations[0].date_obs, observations[0].resultat_obs)\n\n# Qualité Rivières — water quality stations\nstations = client.qualite_rivieres.get_stations(\n    params=StationPcParams(code_departement=[\"75\"], size=3)\n)\nprint(stations[0].code_station, stations[0].libelle_station)\n\n# Eau potable — drinking water analyses for a commune\nfrom hubeau_data.models.eau_potable import ResultatEauPotableParams\nresultats = client.eau_potable.get_resultats_dis(\n    params=ResultatEauPotableParams(code_commune=[\"75056\"], size=5)\n)\nprint(resultats[0].libelle_parametre, resultats[0].resultat_numerique)\n\n# Phytopharmaceutiques — national pesticide sales\nfrom hubeau_data.models.phytopharmaceutiques import VenteSubstanceParams\nventes = client.phytopharmaceutiques.get_ventes_substances(\n    params=VenteSubstanceParams(type_territoire=\"National\", size=5)\n)\nprint(ventes[0].libelle_substance, ventes[0].quantite, ventes[0].annee)\n\n# API health check — works on every API\nreport = client.hydrometrie.check_health(n_requests=3)\nprint(report.summary())\n\n# Data coverage — spot-check stations\ncov = client.hydrometrie.data_coverage(code_station=\"Y120201001\")\nprint(cov.summary())\n```\n\n## Async client\n\nFor bulk data collection — e.g. fetching many stations before inserting into a database —\n`AsyncHubeauClient` mirrors the sync client and supports `asyncio.gather()` for parallel requests:\n\n```python\nimport asyncio\nfrom hubeau_data.async_client import AsyncHubeauClient\nfrom hubeau_data.models.hydrometrie import ObservationTrParams\n\nasync def main():\n    async with AsyncHubeauClient() as client:\n        codes = [\"Y120201001\", \"K418001001\", \"A1234567\"]\n        tasks = [\n            client.hydrometrie.get_observations_tr(\n                params=ObservationTrParams(code_station=[c], size=10)\n            )\n            for c in codes\n        ]\n        results = await asyncio.gather(*tasks)\n        for code, obs in zip(codes, results):\n            print(code, len(obs), \"observations\")\n\nasyncio.run(main())\n```\n\nAll 11 APIs are available on `AsyncHubeauClient` with the same method names as the sync client\n(`get_sites`, `get_stations`, etc.) — just `await` them. Retry logic (tenacity) applies to async\nrequests too. `check_health` and `data_coverage` are sync-only (diagnostic tools, not bulk operations).\n\n## API Coverage\n\n| API | Status | Notes |\n|-----|--------|-------|\n| **Hydrométrie** | ✅ Supported | Sites, stations, real-time and elaborated observations |\n| **Qualité des cours d'eau** | ⚠️ Partial | Stations and analyses. Upstream API has known stability issues |\n| **Piézométrie** | ✅ Supported | Stations, chroniques, chroniques temps réel |\n| **Qualité des nappes** | ⚠️ Partial | Stations and analyses. Known 503/timeout issues |\n| **Écoulement** | ✅ Supported | Stations, observations, campaigns |\n| **Température** | ✅ Supported | Stations and chroniques |\n| **Prélèvements en eau** | ✅ Supported | Ouvrages, points de prélèvement, chroniques |\n| **Hydrobiologie** | ✅ Supported | Stations, indices (IBGN/IBMR/IBD/IPR), taxons |\n| **Poisson** | ✅ Supported | Stations, indicateurs IPR/IPR+, observations, operations |\n| **Qualité eau potable** | ✅ Supported | Communes/UDI links, analysis results |\n| **Phytopharmaceutiques** | ✅ Supported | Purchases and sales by substance and product |\n| **Surveillance Littoral** | 🚫 Skipped | API being decommissioned by Hub'Eau |\n| **Indicateurs Services** | 🚧 Maintenance | API under maintenance — see services.eaufrance.fr |\n\nAll supported APIs expose `check_health(n_requests)` and `data_coverage(...)`, and are available\non both `HubeauClient` (sync) and `AsyncHubeauClient` (async, except health/coverage).\n\n## Features\n\n- Pydantic v2 models for all responses — strict runtime validation, IDE autocomplete\n- Typed query `Params` models for every endpoint — no more `**kwargs`\n- Sync (`HubeauClient`) and async (`AsyncHubeauClient`) clients, same method names\n- Automatic retry with exponential backoff (tenacity) on transient errors — Hub'Eau APIs have known stability issues\n- `check_health(n_requests)` — latency stats per endpoint, healthy ratio\n- `data_coverage(...)` — data availability windows per station or territory\n- Optional extras: `[dataframe]`, `[geo]`, `[viz]` — install only what you need\n\n## Stack\n\n- Python 3.13+, `mypy --strict`, `ruff`, `uv`, `hatchling`, src-layout\n- `httpx` + `tenacity` for resilient sync/async HTTP\n- `pytest-httpx` mocked test suite — CI runs without network dependency\n\n## Installation \u0026 Development\n\n```zsh\ngit clone https://github.com/pfei/hubeau-data.git\ncd hubeau-data\nuv sync                   # core only\nuv sync --all-extras      # with pandas, geopandas, matplotlib\n```\n\n```zsh\nuv run ruff check .           # lint\nuv run mypy .                 # type check\nuv run pytest -m \"not live\"   # fast mocked tests (CI)\nuv run pytest -m \"live\" -s    # real network integration tests\n```\n\n## Examples \u0026 Scripts\n\n```zsh\nuv run python examples/demo.py\nuv run jupyter lab            # open examples/demo.ipynb\n```\n\nHealth check scripts for every API under `scripts/\u003capi\u003e/check_health.py`:\n\n```zsh\nuv run python scripts/hydrometrie/check_health.py --n-requests 3 --random\nuv run python scripts/qualite_rivieres/check_health.py --n-requests 2\nuv run python scripts/eau_potable/check_health.py --commune 75056\nuv run python scripts/phytopharmaceutiques/check_health.py\n```\n\nExploration scripts under `scripts/qualite_rivieres/` and `scripts/hydrometrie/`.\n\n## Roadmap\n\n- [x] Full Hub'Eau API coverage (11 APIs implemented)\n- [x] `check_health` and `data_coverage` on all APIs\n- [x] Typed `Params` models for every endpoint\n- [x] Automatic retry with exponential backoff (tenacity)\n- [x] Async client (`AsyncHubeauClient`, all 11 APIs)\n- [x] Optional dependency groups — `pandas`, `geopandas`, `matplotlib` as extras\n- [x] `CHANGELOG.md` + `CONTRIBUTING.md`\n- [ ] PyPI release\n\n## License\n\nMIT © Pierre Feilles\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfei%2Fhubeau-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpfei%2Fhubeau-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfei%2Fhubeau-data/lists"}