# Hydrology API
**This package was build for my own use, please feel free to use it but it may have bugs**
This package loads data from the UK [Hydrology API](https://environment.data.gov.uk/hydrology/doc/reference).
The API provides:
- River Level, Flow and Water Quality Data
- Rainfall Data
- Groundwater Level Data
This package currently only provides access to the River Level, Flow, and Rainfall. Data is returned as a polars DataFrame.
After the first request of a given dataset, the data is cached for up to a week.
## Example
```python
>>> from hydrology import HydrologyApi, Measure
>>> from datetime import datetime
>>> api = HydrologyApi()
>>>
>>> # Get all stations that record the water level along the River Wear in Durham
>>> stations = api.get_stations(Measure.MeasureType.LEVEL, river="River Wear")
>>>
>>> df = api.get_measures(
>>> [
>>> Measure(station_id, Measure.MeasureType.LEVEL) for station_id in stations["station_id"]
>>> ],
>>> stations,
>>> start_date=datetime(2020, 1, 1),
>>> )
>>>
>>> df.head()
shape: (5, 6)
┌────────────────┬────────────────┬────────────────┬───────────────┬───────────────┬───────────────┐
│ timestamp ┆ Durham New ┆ Sunderland ┆ Chester Le ┆ Witton Park ┆ Stanhope │
│ --- ┆ Elvet Bridge ┆ Bridge ┆ Street ┆ level-i-900-m ┆ level-i-900-m │
│ datetime[μs] ┆ level-… ┆ level-i-900-… ┆ level-i-900-… ┆ --- ┆ --- │
│ ┆ --- ┆ --- ┆ --- ┆ f32 ┆ f32 │
│ ┆ f32 ┆ f32 ┆ f32 ┆ ┆ │
╞════════════════╪════════════════╪════════════════╪═══════════════╪═══════════════╪═══════════════╡
│ 2020-01-01 ┆ 0.372 ┆ 0.417 ┆ 0.465 ┆ 0.465 ┆ 0.344 │
│ 00:00:00 ┆ ┆ ┆ ┆ ┆ │
│ 2020-01-01 ┆ 0.379 ┆ 0.418 ┆ 0.465 ┆ 0.465 ┆ 0.344 │
│ 00:15:00 ┆ ┆ ┆ ┆ ┆ │
│ 2020-01-01 ┆ 0.378 ┆ 0.417 ┆ 0.464 ┆ 0.465 ┆ 0.344 │
│ 00:30:00 ┆ ┆ ┆ ┆ ┆ │
│ 2020-01-01 ┆ 0.371 ┆ 0.417 ┆ 0.464 ┆ 0.465 ┆ 0.344 │
│ 00:45:00 ┆ ┆ ┆ ┆ ┆ │
│ 2020-01-01 ┆ 0.367 ┆ 0.417 ┆ 0.467 ┆ 0.465 ┆ 0.344 │
│ 01:00:00 ┆ ┆ ┆ ┆ ┆ │
└────────────────┴────────────────┴────────────────┴───────────────┴───────────────┴───────────────┘
```
Raw data
{
"_id": null,
"home_page": null,
"name": "hydrology",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": "Hydology, API, UK, Water, Data, Environment Agency, River, Flood, Rain, Weather",
"author": "Edward Jex",
"author_email": "edwardjex@live.co.uk",
"download_url": "https://files.pythonhosted.org/packages/e0/66/e41e15c5dc3c166eafa6b1c62ca28126715a00ae7ed8ec3754ea84f24b79/hydrology-4.0.2.tar.gz",
"platform": null,
"description": "# Hydrology API\n\n**This package was build for my own use, please feel free to use it but it may have bugs**\n\nThis package loads data from the UK [Hydrology API](https://environment.data.gov.uk/hydrology/doc/reference).\nThe API provides:\n\n- River Level, Flow and Water Quality Data\n- Rainfall Data\n- Groundwater Level Data\n\nThis package currently only provides access to the River Level, Flow, and Rainfall. Data is returned as a polars DataFrame.\nAfter the first request of a given dataset, the data is cached for up to a week.\n\n## Example\n\n```python\n>>> from hydrology import HydrologyApi, Measure\n>>> from datetime import datetime\n>>> api = HydrologyApi()\n>>> \n>>> # Get all stations that record the water level along the River Wear in Durham\n>>> stations = api.get_stations(Measure.MeasureType.LEVEL, river=\"River Wear\")\n>>> \n>>> df = api.get_measures(\n>>> [\n>>> Measure(station_id, Measure.MeasureType.LEVEL) for station_id in stations[\"station_id\"]\n>>> ],\n>>> stations,\n>>> start_date=datetime(2020, 1, 1),\n>>> )\n>>> \n>>> df.head()\nshape: (5, 6)\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 timestamp \u2506 Durham New \u2506 Sunderland \u2506 Chester Le \u2506 Witton Park \u2506 Stanhope \u2502\n\u2502 --- \u2506 Elvet Bridge \u2506 Bridge \u2506 Street \u2506 level-i-900-m \u2506 level-i-900-m \u2502\n\u2502 datetime[\u03bcs] \u2506 level-\u2026 \u2506 level-i-900-\u2026 \u2506 level-i-900-\u2026 \u2506 --- \u2506 --- \u2502\n\u2502 \u2506 --- \u2506 --- \u2506 --- \u2506 f32 \u2506 f32 \u2502\n\u2502 \u2506 f32 \u2506 f32 \u2506 f32 \u2506 \u2506 \u2502\n\u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561\n\u2502 2020-01-01 \u2506 0.372 \u2506 0.417 \u2506 0.465 \u2506 0.465 \u2506 0.344 \u2502\n\u2502 00:00:00 \u2506 \u2506 \u2506 \u2506 \u2506 \u2502\n\u2502 2020-01-01 \u2506 0.379 \u2506 0.418 \u2506 0.465 \u2506 0.465 \u2506 0.344 \u2502\n\u2502 00:15:00 \u2506 \u2506 \u2506 \u2506 \u2506 \u2502\n\u2502 2020-01-01 \u2506 0.378 \u2506 0.417 \u2506 0.464 \u2506 0.465 \u2506 0.344 \u2502\n\u2502 00:30:00 \u2506 \u2506 \u2506 \u2506 \u2506 \u2502\n\u2502 2020-01-01 \u2506 0.371 \u2506 0.417 \u2506 0.464 \u2506 0.465 \u2506 0.344 \u2502\n\u2502 00:45:00 \u2506 \u2506 \u2506 \u2506 \u2506 \u2502\n\u2502 2020-01-01 \u2506 0.367 \u2506 0.417 \u2506 0.467 \u2506 0.465 \u2506 0.344 \u2502\n\u2502 01:00:00 \u2506 \u2506 \u2506 \u2506 \u2506 \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n",
"bugtrack_url": null,
"license": "LICENCE",
"summary": "Load data from the UK Hydology API",
"version": "4.0.2",
"project_urls": null,
"split_keywords": [
"hydology",
" api",
" uk",
" water",
" data",
" environment agency",
" river",
" flood",
" rain",
" weather"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5ad714431c3a89adb88c9d04339fab137562e4b41e8827730889b1ef4fbc3b28",
"md5": "6a45da714464a745dcc71da42bd23c92",
"sha256": "435d4945dca70282214e3b043811a55075e9634f0bce2e2f4f77868031fc992d"
},
"downloads": -1,
"filename": "hydrology-4.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6a45da714464a745dcc71da42bd23c92",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 9694,
"upload_time": "2024-07-20T21:26:47",
"upload_time_iso_8601": "2024-07-20T21:26:47.692102Z",
"url": "https://files.pythonhosted.org/packages/5a/d7/14431c3a89adb88c9d04339fab137562e4b41e8827730889b1ef4fbc3b28/hydrology-4.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e066e41e15c5dc3c166eafa6b1c62ca28126715a00ae7ed8ec3754ea84f24b79",
"md5": "ddf6511e7275a22abfc0275a55cbd97f",
"sha256": "f11b7da8c634e18df6460b2eec0720296112d736fa4b0757cc1365ad188a714e"
},
"downloads": -1,
"filename": "hydrology-4.0.2.tar.gz",
"has_sig": false,
"md5_digest": "ddf6511e7275a22abfc0275a55cbd97f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 8266,
"upload_time": "2024-07-20T21:26:48",
"upload_time_iso_8601": "2024-07-20T21:26:48.563112Z",
"url": "https://files.pythonhosted.org/packages/e0/66/e41e15c5dc3c166eafa6b1c62ca28126715a00ae7ed8ec3754ea84f24b79/hydrology-4.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-20 21:26:48",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "hydrology"
}