This page describes the web interface for direct access to river flow data from the UK National River Flow Archive (NRFA). It is designed primarily for programmers (API stands for Application Programming Interface), to enable rapid access to large numbers of datasets. All of the data provided can also be manually downloaded, through a set of user-friendly web-pages, via the NRFA website, including an easy to use map-based search page. We recommend that non-programmers access NRFA data in this way.
This is a test service to help us to understand user needs. It is possible that the services provided, including url patterns, parameters, and formats of data returned, will change prior to release of an operational service. Once the operational service is released we will endeavour to ensure changes are managed in a way to assist continuity of use.
By using this NRFA API you are agreeing to the terms and conditions of use. See Terms and conditions of use / Licence below.
The following acknowledgement shall, unless otherwise stated, be used on all copies of the Data, publications and reports, including but not limited to, use in presentations to any audience.
Acknowledgement: Data from the UK National River Flow Archive
The NRFA is the UK's focal point for river flow data. We collate, quality control and archive hydrometric data from gauging station networks across the UK including the extensive networks operated by the Environment Agency (England), Natural Resources Wales, the Scottish Environment Protection Agency and the Department for Infrastructure - Rivers. For information on the work of the NRFA, see our website.
This API provides access to NRFA river flow gauging station information, including station metadata (the type of station, its location and key characteristics), information about the station's catchment (land use, geology, climate, etc.), and time series of daily river flows measured at the station.
Please see here for information about the NRFA Data Update Schedule.
By using this service you are agreeing to conform to the NRFA API licence, covering use of the data and the API. The licence can be found here:
NRFA Data Terms and Conditions for access to time-series data and metadata
Currently there are no controls or restrictions in using this API, but this may not always be the case.
Calls to the NRFA API should follow this basic pattern:
https://nrfaapps.ceh.ac.uk/nrfa/ws/web-service[/path]?query-string
where:
https://nrfaapps.ceh.ac.uk/nrfa/ws
web-service
[/path]
?query-string
Note: Some characters are utilised by URLs for special use in defining their syntax. The forward slash
and colon /
characters are examples of such special characters. When these special characters are not used in their special role inside a URL, they must be encoded.:
station-ids | Return a list of all NRFA station identifiers. |
station-info | Return station metadata for one or more NRFA stations. |
time-series | Return time-series data for a single station and data-type. |
station-ids
https://nrfaapps.ceh.ac.uk/nrfa/ws/station-ids[/path]?query-string
Returns a list of NRFA station identifiers. These station identifiers can then be used as values for the station
parameter of other web-services to return data for that particular station.
Required parameters:
format
(must be one of the tabular formats)Optional parameters:
format
parameter is not needed.station-info
https://nrfaapps.ceh.ac.uk/nrfa/ws/station-info[/path]?query-string
Returns one or more items of metadata for one or more NRFA stations.
Required parameters:
station
format
(must be one of the tabular formats)Optional parameters:
The fields
parameter consists of a comma separated list of codes that determine the station metadata that is to be returned:
fields=code,code,...
id
name
default
id
and name
fields.catchment-area
grid-reference
grid-reference
is represented as an object with the following properties: ngr
SS9360201602
).easting
northing
lat-long
lat-long
is represented as an object with the following properties: string
50°48'15.0265"N 3°30'40.7121"W
).latitude
longitude
river
location
station-level
easting
northing
station-information
id
, name
, catchment-area
, grid-reference
, lat-long
, river
, location
, station-level
, measuring-authority-id
, measuring-authority-station-id
, hydrometric-area
, opened
, closed
, station-type
, bankfull-flow
, structurefull-flow
, sensitivity
.category
nrfa-mean-flow
, nrfa-peak-flow
, feh-pooling
, feh-qmed
, feh-neither
, nhmp
, benchmark
, live-data
, eflag
, historic-droughts
, marius
, outlook-analogues
, outlook-esp
.catchment-information
factors-affecting-runoff
.gdf-statistics
gdf-start-date
, gdf-end-date
, gdf-mean-flow
, gdf-min-flow
, gdf-first-date-of-min
, gdf-last-date-of-min
, gdf-max-flow
, gdf-first-date-of-max
, gdf-last-date-of-max
, gdf-q95-flow
, gdf-q70-flow
, gdf-q50-flow
, gdf-q10-flow
, gdf-q05-flow
, gdf-base-flow-index
, gdf-day-count
, gdf-flow-count
.peak-flow-statistics
peak-flow-start-date
, peak-flow-end-date
, qmed
.elevation
minimum-altitude
, 10-percentile-altitude
, 50-percentile-altitude
, 90-percentile-altitude
, maximum-altitude
.catchment-rainfall
saar-1941-1970
, saar-1961-1990
.lcm2000
lcm2000-woodland
, lcm2000-arable-horticultural
, lcm2000-grassland
, lcm2000-mountain-heath-bog
, lcm2000-urban
.lcm2007
lcm2007-woodland
, lcm2007-arable-horticultural
, lcm2007-grassland
, lcm2007-mountain-heath-bog
, lcm2007-urban
.geology
high-perm-bedrock
, moderate-perm-bedrock
, low-perm-bedrock
, mixed-perm-bedrock
, high-perm-superficial
, low-perm-superficial
, mixed-perm-superficial
.feh-descriptors
propwet
, bfihost
, farl
, dpsbar
.urban-extent
urbext-1990
, urbext-2000
.spatial-location
easting
, northing
, latitude
, longitude
.peak-flow-metadata
peak-flow-rejected-amax-years
, peak-flow-rejected-periods
.data-summary
description
licence-url
, description-summary
, description-general
, description-station-hydrometry
, description-flow-record
, description-catchment
, description-flow-regime
.all
time-series
This web-service is used to retrieve time-series data.
Required parameters:
station
— only a single station may be specifieddata-type
— only a single data-type may be specifiedformat
— must be one of the time-series formats: json-object
, nrfa-csv
, feh-data
or feh-csv
Optional parameters:
When the format
parameter is specified as nrfa-csv
the time-series data is returned in traditional
NRFA CSV format. This is the same format that is returned when using the Download flow data
button on the Daily Flow Data
tab of a station page.
The returned object has the following properties:
timestamp
interval
repeating intervalformat string indicating the date/time range and period of the returned data. This string is in the format
Rsize/start/period
where: period
durationstring containing the period of the data in the time-series. For a daily time-series this will be
P1D
and for a monthly time-series this will be P1M
. For fifteen-minute sub-daily data this will be PT15M
.size
period
units between the start and end of the time-series. For example, for a daily time-series this is the number of days between the start and end of the series. For sparse time-series data-types, such as pot-flow
and pot-stage
, the number of values in the time-series will be considerably less than the size
.start
period
. For daily data where period
is P1D
the format of start
will be yyyy-mm-dd
. For monthly data where period
is P1M
the format of start
will be yyyy-mm
.station
id
name
data-type
id
name
parameter
Flow
or Stage
as appropriate for the data-type.units
m3/s
and for stage data-types the units are m
.measurement-type
data-stream
The values in the array can have the following JSON types:
Code that reads the values in the data-stream
property will use a date/time cursor to build up the time-series. String date/time values are used to set the position of the cursor, and number values set the value at the cursor position and advance the cursor to the next date/time position. By default, every time-series value is preceded by the date/time on which it occurs. If the dates=false
parameter is specified (see here) then only the starting date/time of a sequential block of data is returned. The date/time values within the block can be calculated by the code reading the data. The Working example below incorporates JavaScript code (here) that processes the data-stream
array.
Note: All NRFA time-series date/time values are in UTC.
When the format
parameter is specified as feh-data
the time-series data is returned in FEH data format. This is the format used for the
and .AM
files contained in the NRFA Peak Flow Dataset. This format is only valid for AMAX and POT data-types (.PT
amax-stage
, amax-flow
, pot-stage
and pot-flow
).
When the format
parameter is specified as feh-csv
the time-series data is returned in FEH CSV format. This is the format used for the
files contained in the Peak-flow data release Zip files. This format is only valid for POT data-types (.CSV
pot-stage
and pot-flow
).
The pipe
, start-date
, end-date
and date-range
parameters are ignored when either the feh-data
or feh-csv
format is specified.
.AM
format:amax-stage
or amax-flow
and the result will be the same (the file contains both stage and flow values).The query string of the URL consists of a set of parameter name/value pairs. There are standard parameters that are common to all web-services:
station
Specifies one or more NRFA stations.
station=station-id
station-id
.station=station-id,station-id,...
*
Depending on the context in which the station
parameter is used one or more of the formats decribed above may not be legal (i.e. a web-service might allow only a single station to be specified).
data-type
Specifies one or more time-series data-types.
data-type=dt
data-type=dt,dt,...
Depending on the context in which the data-type
parameter is used one or more of the formats decribed above may not be legal (i.e. a web-service might allow only a single data-type to be specified).
The following data-types are available:
gdf
ndf
gmf
nmf
cdr
cdr-d
cmr
pot-stage
pot-flow
gauging-stage
gauging-flow
amax-stage
amax-flow
format
Specifies the format of the returned data.
For web-services returning tabular data the following values can be specified for the format
parameter:
csv
comma separated valueformat. The
Content-Type
header of the HTTP response is set to text/csv
.html
Content-Type
header of the HTTP response is set to text/html
.json-array
json-object
For both the json-array
and json-object
formats the Content-Type
header of the HTTP response is set to either application/json
or application/javascript
depending on whether the callback
parameter has been specified.
For web-services returning time-series data the following values can be specified for the format
parameter:
json-object
nrfa-csv
traditionalNRFA CSV format.
feh-data
feh-csv
start-date
, end-date
, date-range
The start-date
, end-date
and date-range
parameters can be used to limit the returned data to a subset of the entire time-series. If either start-date
or end-date
is specified then date-range
cannot be specified. If date-range
is specified then neither start-date
nor end-date
can be specified.
start-date=start
end-date=end
date-range=start+end
/
character). The resulting time-series will only include data within the specified date/time range. For example, date-range=1980
will return data only for calendar year 1980, and date-range=1980/1989
will return only data between calendar years 1980 and 1989.The start-date
, end-date
and date-range
parameters are ignored when either the feh-data
or feh-csv
format is specified.
pipe
Specifies one or more pipe-line stages to be applied to a time-series data-set. The pipe
parameter can only be specified for the time-series
web-service.
pipe=pipe-spec
|
character.The following pipe-line stages are currently supported:
lower-envelope
lower envelopeof the time-series data.
upper-envelope
upper envelopeof the time-series data.
date-range:start[:end]
date-range:yyyy
to include only data within calendar year yyyy.aggregate:function:period[:missing-criteria]
count
sum
mean
min
max
p5
p95
pn
durationformat string. Typical values include:
p1d
A calendar day.p1m
A calendar month.p1y
A calendar year.-
Generate an output value whenever possible, regardless of the completeness of the input data.mn
Calculate a value only if there are no more than n values missing in the period.pn
Calculate a value only if there are at least n input values in the period.n%
Calculate a value only if the data in the period is at least n percent complete.Note: Both the vertical-bar
character and the colon |
character should be escaped to ensure that the URL is processed correctly.:
pipe
parameter is ignored when either the feh-data
or feh-csv
format is specified. flags
Specifies whether time-series flags are to be returned. The flags
parameter can only be specified for the time-series
web-service and only when the format is set to json-object
.
flags=boolean
true
or false
. false
true
estimatedor
suspectthen write out the value as a JSON array
[value,flag]
else just write out value
.dates
Specifies when the date/time of a time-series value is to be output. The dates
parameter can only be specified for the time-series
web-service and only when the format is set to json-object
.
dates=boolean
true
or false
. false
dates=false
can significantly reduce the download size for certain data-types.true
encoding
Specifies the character set encoding to be used for text output. If encoding
is not specified then character data is encoded using the utf-8
encoding. Other possible encodings include utf-16
, utf-16be
, utf-16le
, utf-32
, utf-32be
, utf-32le
and us-ascii
. If the output format is not character based then this parameter is ignored.
callback
This parameter is used when you wish to return data in JSONP format rather than JSON format. It is ignored if the output format is not JSON. To specify JSON format output set the format
parameter to either json-array
or json-object
. The value of the callback
parameter is the name of the JavaScript function to be called.
The following headers may be set in the HTTP request:
Accept-Encoding
gzip
and deflate
encoding, as well as the identity
encoding. It is recommended that the gzip
encoding be used where possible to reduce network traffic.The following headers are set in the HTTP response:
Access-Control-Allow-Origin
Content-Encoding
Cache-Control
Content-Disposition
Content-Type
If the status code indicates an error (i.e. is anything other than 200) then the Content-Type
is set to text/html
and the response contains HTML that will hopefully provide more details about what went wrong.