# England River Levels — Latest Gauge Readings (`resourcefully_dialect/england-river-levels`) Actor

Export public Environment Agency water-level measurements with station location, original unit, reading time and freshness flags.

- **URL**: https://apify.com/resourcefully_dialect/england-river-levels.md
- **Developed by:** [Biosick Johnny](https://apify.com/resourcefully_dialect) (community)
- **Categories:** Other, Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.00 / 1,000 result rows

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## England River Levels — Latest Gauge Readings

Export the latest available water-level readings from the Environment Agency's public monitoring network in England. Get one clean row per measure, including its station, river, location, original unit, reading time and freshness flags. No source API key or login is required.

Use the feed for environmental dashboards, hydrology research, station inventories with current measurements, and scheduled data exports into a spreadsheet or database. Apify can export the dataset as JSON, CSV, Excel and other supported formats after deployment.

### Quick start

```json
{
  "riverName": "River Thames",
  "maxItems": 100,
  "staleAfterHours": 24,
  "proxyConfiguration": { "useApifyProxy": false }
}
```

River, town and catchment names use the source's **exact, case-sensitive spelling**. Use `River Thames`, not `Thames`. All supplied filters are combined. For one known gauge, use `stationReference`, for example `3400TH`. Leave filters blank to search the available England network. Start with a small maximum.

### What you receive

Each row identifies a **measure**, not a whole station. One gauge may expose upstream/downstream readings or several units and therefore return multiple rows. For example, `mASD` is relative to a station datum while `mAOD` is relative to Ordnance Datum; they must not be treated as interchangeable river depths or compared across gauges as a flood ranking.

The complete real sample is in [SAMPLE_OUTPUT.json](./SAMPLE_OUTPUT.json). The most useful fields are:

| Fields | Meaning |
| --- | --- |
| `measureId`, `stationReference`, `stationName` | Stable source measure identity and station information |
| `riverName`, `town`, `catchmentName` | Source location labels, when published |
| `latitude`, `longitude`, `stationStatus` | Published coordinates and station status |
| `value`, `unit`, `qualifier`, `periodSeconds` | Original measurement, its unit, context and nominal measurement period |
| `readingDateTime`, `readingAgeHours` | Reading timestamp and age at readings retrieval |
| `isStale`, `readingInFuture`, `hasReading` | Explicit data-quality/freshness flags |
| `stationUrl`, `readingUrl`, `retrievedAt` | Primary-source links and UTC retrieval timestamp |
| `source`, `licence`, `attribution` | Source credit and reuse information |

Missing optional metadata is `null`. Zero and negative values are preserved. A reading without a finite scalar value or a timezone-qualified timestamp is treated as missing. Stale values are flagged and retained. If `includeMissingReadings` is false, measures without a valid reading are omitted; if true, they have `value`, `readingDateTime`, `readingAgeHours` and freshness flags set to `null`, and `hasReading: false`.

### Input

| Input | Default | Details |
| --- | --- | --- |
| `riverName` | empty | Exact river name |
| `town` | empty | Exact source town name |
| `catchmentName` | empty | Exact catchment name |
| `stationReference` | empty | Exact Environment Agency reference; also narrows the readings feed |
| `search` | empty | Source text search in station labels |
| `maxItems` | 100 | Hard maximum delivered measure rows, 1–10,000 |
| `pageSize` | 100 | Station page size, 1–500; smaller pages require more requests |
| `staleAfterHours` | 24 | Age above which `isStale` is true; integer 1–8,760 |
| `includeMissingReadings` | false | Include null-reading rows; these also count and are billable if enabled |
| `requestIntervalMillis` | 1,000 | Minimum time between request starts, 1,000–60,000 ms |
| `maxRequests` | 100 | Maximum source HTTP attempts including retries and empty end pages, 2–1,000 |
| `proxyConfiguration` | direct | Optional Apify/custom proxy configuration; no source proxy is required |

Text filters are at most 200 characters. Unknown input fields are rejected. Optional proxies need the user's own later configuration and can carry provider costs. They are not rotated to bypass access restrictions.

### Output example

A shortened real row collected on 26 October 2026 (historical sample, not a current observation):

```json
{
  "measureId": "https://environment.data.gov.uk/flood-monitoring/id/measures/3400TH-level-stage-i-15_min-mASD",
  "stationReference": "3400TH",
  "stationName": "Kingston",
  "riverName": "River Thames",
  "unit": "mASD",
  "qualifier": "Stage",
  "value": 4.548,
  "readingDateTime": "2026-10-26T16:30:00.000Z",
  "readingAgeHours": 0.337,
  "hasReading": true,
  "isStale": false
}
```

The complete verified record, with source links and attribution, is in [SAMPLE_OUTPUT.json](./SAMPLE_OUTPUT.json). Retrieve the source again for current observations.

### Pricing

Price: **$2.00 per 1,000 delivered measure rows** ($0.002 per dataset item), no start fee, billed via Apify pay-per-event (`apify-default-dataset-item` only). Source data is free; Apify platform usage for a run is included in the price shown on the Actor page. The charge pays for the maintained Actor, normalization and Apify integration.

`maxItems` bounds row count. A missing-reading row costs the same if you explicitly enable it. Repeated measures within one run are deduplicated. Scheduled runs are independent snapshots: receiving the same measure again in a new run is a new result. An empty result creates no result event. Network failures before delivery create no result event; a storage failure can leave already delivered and charged rows.

### Reliability and source etiquette

The Actor uses the official JSON API with one request at a time. It reads the bulk latest-readings feed and joins it to station pages, avoiding one latest-reading request per station. An exact station reference narrows the readings request. The source recommends collecting latest readings **no more often than every 15 minutes**; use that minimum schedule interval.

Transient network errors, HTTP 408, 429 and 5xx responses get up to three retries with backoff. `Retry-After` is honored; a requested wait over two minutes stops the run so it can be retried later. Other rejected HTTP requests and malformed response envelopes fail immediately. The request budget is enforced across both phases and all retries.

Station pages can contain fewer distinct stations than the requested limit. Pagination continues until an empty page, an output cap, or a failure, and deduplicates by measure identity. Exhausted retries, unexpected pagination, repeated pages and request-budget exhaustion fail the run before any dataset rows are written. Results are prepared in memory before delivery; an aborted preparation does not deliver a partial scan.

`RUN_SUMMARY` in the default key-value store records `stopReason` (`sourceExhausted`, `maxItems`, or `budgetReached`), request/retry counts, scan counts and missing/invalid readings. If `maxItems` was reached, the result is intentionally capped; it is not a complete network export. All rows share the readings retrieval time. The separate source calls are not a transactional snapshot, so a station or reading can change during a run.

### FAQ

**Does it cover all of the UK?** The source is the Environment Agency network in England and may include cross-border gauges. Scotland, Wales and Northern Ireland have separate services; no complete UK coverage is promised.

**Are these flood warnings, forecasts or historical records?** This Actor returns the latest published measurements only. It does not determine flood severity, provide forecasts or reconstruct a complete historical time series. Store snapshots yourself if useful, but readings can arrive in batches between runs.

**Why is a reading old?** Measurement and transmission schedules differ by station. A nominal 15-minute sampling period does not guarantee a new published observation every 15 minutes. Consult `readingDateTime` and the freshness fields.

**Why are there fewer rows than requested?** There may be fewer matching measures, missing readings are excluded by default, or the user spending cap was reached. Check `RUN_SUMMARY`. An unknown exact river name can legitimately return zero rows.

**Can I resume a failed run in the same dataset?** Preparation can be rerun while the dataset is empty. If a process is restarted after it began delivery, a non-empty dataset is rejected to prevent duplicate rows and billing. Start a fresh run and inspect any already delivered rows. Automatic continuation of partially delivered datasets is not supported.

**Can I use the source directly?** Yes. The [official API](https://environment.data.gov.uk/flood-monitoring/doc/reference) is public, free and keyless. This Actor supplies convenient maintained output and platform integration.

### Run locally

Requires Node.js 22 or later. From this Actor directory:

```sh
npm ci
npm test
npm run smoke
```

In this workspace npm was bootstrapped locally because it was absent from PATH. The equivalent commands are:

```sh
node ../.tools/npm/bin/npm-cli.js ci --cache ../.npm-cache
node ../.tools/npm/bin/npm-cli.js test --cache ../.npm-cache
node scripts/smoke.js live
```

The smoke script runs `node src/main.js` in a fresh local storage directory, supplies the sample input, excludes account credentials from its environment, verifies five rows against their exact official reading URLs, and refreshes the sample. It enables process-only local memory metrics because this machine's restricted environment prevents Crawlee from spawning `ps`; cloud runs keep standard Apify container metrics.

Additional checks:

```sh
node scripts/smoke.js empty
node scripts/smoke.js budget
node scripts/smoke.js zero-budget
```

Budget mode uses the SDK's local PPE simulation ($1 per synthetic event) with a $2 limit; it spends no money. Do not enable local PPE test variables on Apify.

For a manual run, put your JSON input in `storage/key_value_stores/default/INPUT.json`, then run:

```sh
env -u APIFY_IS_AT_HOME APIFY_PURGE_ON_START=false APIFY_LOCAL_STORAGE_DIR=./storage CRAWLEE_STORAGE_DIR=./storage CRAWLEE_LOCAL_PROCESS_METRICS=true node src/main.js
```

Use a fresh storage directory for each independent run. Leave `APIFY_IS_AT_HOME` unset locally: the pinned SDK treats any nonempty value, including `false`, as cloud mode. The Dockerfile uses the official Apify Node.js 22 image, a lockfile and production-only dependencies.

### Source, licence and legal note

[Environment Agency flood-monitoring API (Beta)](https://environment.data.gov.uk/flood-monitoring/doc/reference). The source expressly provides programmatic access without registration under the [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/).

**This uses Environment Agency flood and river level data from the real-time data API (Beta).** Keep this credit and the licence when redistributing output. This is an independent tool with no Environment Agency endorsement. It collects public station and sensor data, without personal contact information or private content.

The source is provisional, can be delayed or unavailable, and provides no service guarantee. It must not be relied on for safety-critical decisions; use the [official flood-warning channels](https://www.gov.uk/check-flooding) for those purposes. Review the current source terms and licence before redistribution.

# Actor input Schema

## `riverName` (type: `string`):

Exact, case-sensitive source river name, e.g. River Thames. Empty searches the whole available network.

## `town` (type: `string`):

Exact source town name. All supplied filters are combined.

## `catchmentName` (type: `string`):

Exact source catchment name.

## `stationReference` (type: `string`):

Exact Environment Agency station reference, e.g. 3400TH. This also narrows the readings request.

## `search` (type: `string`):

Source text search in station labels; this is not a river-name search.

## `maxItems` (type: `integer`):

Hard maximum number of measure rows saved. A station can have multiple units or qualifiers and therefore multiple rows.

## `pageSize` (type: `integer`):

Number of underlying station results requested per page. Small pages can contain fewer distinct stations and require more requests.

## `requestIntervalMillis` (type: `integer`):

Minimum delay between request start times. Retries also use backoff and Retry-After.

## `maxRequests` (type: `integer`):

Counts all HTTP attempts, including retries and empty end pages. Exhausting this limit fails preparation instead of delivering a silent partial scan.

## `staleAfterHours` (type: `integer`):

A reading older than this threshold is flagged isStale. This does not remove stale rows or classify flood risk.

## `includeMissingReadings` (type: `boolean`):

Include missing/invalid readings as null values with hasReading false. These rows count toward maxItems and the result price. Default false omits them.

## `proxyConfiguration` (type: `object`):

Direct public API access is the default. Optional custom proxies or Apify Proxy can be supplied; Apify Proxy requires your later account setup and may incur provider costs. Proxies are not rotated to evade source restrictions.

## Actor input object example

```json
{
  "riverName": "River Thames",
  "maxItems": 10,
  "pageSize": 100,
  "requestIntervalMillis": 1000,
  "maxRequests": 100,
  "staleAfterHours": 24,
  "includeMissingReadings": false,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset items produced by the run.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "riverName": "River Thames",
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("resourcefully_dialect/england-river-levels").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "riverName": "River Thames",
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("resourcefully_dialect/england-river-levels").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "riverName": "River Thames",
  "maxItems": 10
}' |
apify call resourcefully_dialect/england-river-levels --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,resourcefully_dialect/england-river-levels"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/qLpxJzqeBqtZubhWi/builds/f13BjXgbt1jLytkwK/openapi.json
