Skip to main content

RivRetrieve

PyPI version Python ≥3.13 Documentation

RivRetrieve is an open-source Python package for finding and downloading river observations (discharge, stage and water temperature) directly from national and regional agencies around the world, through one consistent interface. RivRetrieve also ships a searchable catalogue of gauging stations, harmonises identifiers, units and columns across agencies, and records the source of every retrieval, so that results can be traced back to the original provider. The vision of RivRetrieve is to become a community platform for the world's openly published river data, one that grows as new agencies are added.

River data and where to find them

From floods to droughts: understanding and modelling rivers is a central environmental concern. For that, we need data. Preferably open data. Many countries measure their rivers at thousands of stations, but compiling that information is often hard. Different data portals, different languages, different formats. All of that adds up quickly for anyone interested in the data. The data exist, but accessing them is challenging.

RivRetrieve helps close this gap. It lets you find gauges, choose the physical observations you need, and retrieve them without learning a different Python interface for each agency. The map below shows countries where providers are already implemented and countries where data are coming soon. Currently, RivRetrieve retrieves observations from thirteen different providers in twelve countries.

Countries with implemented providers in solid green and countries coming soon in orange stripes; implemented providers are listed in the table below.

Boundaries: Natural Earth. Their depiction implies no position on territorial status.

RivRetrieve focuses on time series of discharge, stage and water temperature. It leaves source quality judgements and study suitability to the reader. Think of RivRetrieve as a bridge between the original provider and the user.

Some providers require credentials. See the usage guide for how to supply them.

Providers and access
Country Agency Provider Stations Access
Bosnia and Herzegovina Agencija za vodno područje rijeke Save (AVP Sava) ba_fhmzbih 60 Open
Brazil Agência Nacional de Águas e Saneamento Básico (ANA) br_ana 17,914 Credentials required
Canada Environment and Climate Change Canada (ECCC) ca_eccc 8,057 Bulk download
Czechia Czech Hydrometeorological Institute (CHMI) cz_chmi 831 Open
France Hub'Eau fr_hubeau 7,347 Open
France HydroPortail fr_hydroportail 6,409 Open
Japan Ministry of Land, Infrastructure, Transport and Tourism (MLIT) jp_mlit 1,023 Open
Lithuania Lithuanian Hydrometeorological Service (LHMT) lt_lhmt 97 Open
Norway Norwegian Water Resources and Energy Directorate (NVE) no_nve 3,804 Credentials required
Poland Institute of Meteorology and Water Management (IMGW) pl_imgw 1,301 Bulk download
Switzerland Federal Office for the Environment (FOEN) ch_foen 246 Open
Thailand Hydro-Informatics Institute (HII), ThaiWater th_thaiwater 825 Open
United States U.S. Geological Survey (USGS) usgs_nwis 26,201 Open

Station counts show gauges with supported series in the packaged catalogues, not guaranteed current data availability. The USGS catalogue retains 26,258 station identities; 26,201 have selectable modern series in this snapshot. A station can appear under both French services; their series remain separate.

Countries coming soon

Afghanistan, Argentina, Australia, Austria, Belgium, Chile, Colombia, Denmark, Estonia, Finland, Germany, Greece, Ireland, Israel, Italy, Mexico, Netherlands, New Zealand, Peru, Portugal, Rwanda, Slovenia, South Africa, South Korea, Spain, Sweden, Taiwan and the United Kingdom.

Some of these have a fetcher in the legacy RivRetrieve-Python that awaits porting; others come from our survey of national services. Sources differ in what they publish, so a country can arrive with a single agency or a single region first. The map shows whole countries either way.

Know a data source we’re missing? Suggest it in a GitHub issue, with source links and relevant access information.

Install

Requires Python 3.13 or later. We recommend uv:

uv add rivretrieve

It also installs with pip: pip install rivretrieve.

For optional station maps, install the map extra: uv add "rivretrieve[map]".

Use with a coding agent

Copy the prompt below into your coding agent after installing RivRetrieve.

Show agent prompt
Use RivRetrieve to find and retrieve river discharge, stage, and water
temperature observations from national and regional agencies.

Check that rivretrieve imports in the project's Python environment and
note its version. If setup fails, report the error. Do not upgrade it
automatically.

Typical workflow:
import rivretrieve as rr

gauges = rr.find(
    provider="usgs_nwis", quantity="discharge",
    frequency="daily", statistic="mean",
)
selected = rr.pick(gauges, station=["07374000"])
result = rr.fetch(selected, start="2023-01-01", end="2023-01-01")

# Inspect observations, retrieval issues, and source-series outcomes.
result.data
result.issues
rr.series(result)

This illustrates the API; only retrieve data needed for the user's task.
Catalogue searches are offline; fetching contacts providers.

RivRetrieve harmonises units and structure. It does not perform quality
control, gap filling, or aggregation. Read timestamps with their time-zone
information. Returned rows do not imply complete coverage or no failures.

Consult documentation as needed:
- Usage, selections, results, credentials:
  https://rivretrieve.github.io/usage/
- Exact API signatures and returned types:
  https://rivretrieve.github.io/reference/
- Provider-specific access and interpretation:
  follow the relevant provider page from https://rivretrieve.github.io/

Continue the user's task without onboarding questions. If no task was
given, briefly confirm readiness.

Quick start

The packaged catalogue contains station locations and known source-series facts. Searching it does not contact the agencies. The following example then contacts USGS to retrieve one day of daily mean streamflow.

import rivretrieve as rr

# Find daily mean streamflow and choose a gauge.
daily_gauges = rr.find(
    provider="usgs_nwis", quantity="discharge", frequency="daily", statistic="mean"
)

chosen_gauges = rr.pick(daily_gauges, station=["07374000"])

result = rr.fetch(chosen_gauges, start="2023-01-01", end="2023-01-01")

# Inspect two columns as a short list of rows.
print(result.data.select("station_id", "value").rows())

# Output:
# [('07374000', 10562.183778816001)]

print(result.issues)

# Output:
# ()

The displayed values come from a recorded USGS response. Live source responses can change. The empty tuple means this retrieval reported no issues.

result.data is a Polars table of observations. Use rr.series(result) to inspect the returned source series and their outcomes. Discharge values use m³/s. Read timestamps together with their zone column. Inspect result.issues even when rows come back. A successful call does not establish continuous records or scientific comparability. Downloading observations requires internet access.

When an agency publishes different versions for the same variable

Brazil's ANA publishes bruto (raw) and consistido (quality-checked) daily records. ANA performs that checking, not RivRetrieve. Both are available. You choose whether to request both or just one. You can inspect and select them without credentials or network access:

brazil = rr.find(
    provider="br_ana", station="15400000", quantity="stage", frequency="daily", statistic="mean"
)

print(sorted(rr.series(brazil)["variant"].to_list()))

# Output:
# ['bruto', 'consistido']

consistido = rr.pick(brazil, variant="consistido")

print(rr.series(consistido)["variant"].to_list())

# Output:
# ['consistido']

Fetching brazil requests both daily mean water-level series by default. Fetching consistido requests only the quality-checked series. Not every period has observations for both. The usage guide shows the downloads and explains how to supply ANA credentials.

Next: the usage guide builds on the same example and covers selections, time windows, issues, credentials and caching. The CAMELS-US example retrieves streamflow for several gauges at once.

What RivRetrieve does and does not do

  • Choose the observations you need. Search for discharge or narrow to daily means. A source appears in a daily-mean search only when its values are known to be daily means. Two matching records can still differ in ways that matter for your study.
  • No quality control or gap filling. RivRetrieve does not assess scientific quality. It converts units and formats, and reports retrieval and parsing issues. Provider-specific observation quality flags are not added to harmonised output.
  • No aggregation. RivRetrieve does not aggregate data (e.g., from hourly to daily). Data are returned at the time step the provider publishes: daily data are available only where the provider already publishes daily values.
  • No hosting. RivRetrieve does not host or redistribute the data. Downloads come from the providers' own services.
  • Fresh downloads depend on the providers. Service outages or changes can prevent new downloads. Previously cached observations can remain available.

Documentation

Start with the documentation index.

Data rights

Data rights remain with the original providers. The MIT licence in LICENSE applies to RivRetrieve's code, not to provider data, including packaged catalogues, station metadata and downloaded observations. Follow each provider's attribution, citation and reuse conditions. See station metadata rights and the provider pages.

Background

RivRetrieve is under active development. Breaking changes should be expected between release versions. See the issues for what is being worked on.

The package began as a Python translation of RivRetrieve for R by Ryan Riggs, made by Frederik Kratzert with the Gemini CLI and a few manual fixes for API changes. It has grown into a collaborative effort since, with Simon Moulds, Thiago Nascimento and Nicolas Lazaro.

Questions, bug reports and collaboration are welcome through the issues.

Acknowledgements

Importantly, this project would not exist without the open APIs of so many data providers. We thank them for their data and for supporting the philosophy of open data.

We also thank Henning Plessow at the Global Runoff Data Centre (GRDC) for the exchanges leading up to RivRetrieve’s first release. Their R package hydrodownloadR offers related access to station catalogues and daily time series from public national and regional APIs.

Metadata

Release files for rivretrieve 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rivretrieve 0.1.1
File Size Uploaded
rivretrieve-0.1.1.tar.gz 14.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for rivretrieve 0.1.1
File Interpreter ABI Platform
rivretrieve-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 29.5 MB

Release files / rivretrieve-0.1.1.tar.gz

Download URL rivretrieve-0.1.1.tar.gz
Size 14.7 MB
Tags Source
SHA-256 checksum
How to use checksums
56a8df02c49476995ba62c2ad953ed67af311c0935b59db5ef63cb3721d37768
BLAKE2b-256 checksum
How to use checksums
aa75b25b63cbd6ab9e4205b7564dc0e8718f86aaf92f4d2767db4d8f5c8b24e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rivretrieve-0.1.1-py3-none-any.whl

Download URL rivretrieve-0.1.1-py3-none-any.whl
Size 14.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
57b82af36aabf43331d3eaf74d06b7518a66005eaeb975382a777061c4e7e33e
BLAKE2b-256 checksum
How to use checksums
319eae61a8fd9ce99eaefa16a2057a87ae77dc55701f7a641c786525d286edf0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page