Open Data - River Levels API

API change history

Provides information on readings of river levels at our measurement stations across Wales.

All River Levels

River Levels is available as a single GeoJSON data structure, which returns a list of the latest measurements from all our measurement stations.

Returned Properties

Geometry Property Name Geometry Property Description Type
coordinates The Latitude and Longitude of the feature, in WGS84 coordinate ref decimal

Property Name Property Description Type
Location Identifier for the station, as used by River Levels Online decimal
LatestValue The value of the most recent reading decimal
LatestTime The date and time at which the latest reading was taken date
NameEN Name of the station or location in English string
NameCY Name of the station or location in Welsh string
ParamNameEN Name of the parameter being measured in English string
ParamNameCY Name of the parameter being measured in Welsh string
StatusEN The Status of the station (online or offline) in English string
StatusCY The Status of the station (online or offline) in Welsh string
TitleEN Title of the parameter being measured in English string
TitleCY Title of the parameter being measured in Welsh string
Units The units in which this parameter is measured, e.g. qudt:Meter string
url The URI of the monitoring station supplying the measure string
NGR National Grid Reference Number of the station string

Try it

Request

Request URL

Request headers

  • string
    Subscription key which provides access to this API. Found in your Profile.

Request body

Responses

200 OK

Example Response

Representations

{
  "type" : "FeatureCollection", 
  "crs" : 
  {
    "type" : "name", 
    "properties" : 
    {
      "name" : "EPSG:4326"
    }
  }, 
  "features" : [
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -3.61886247432994, 51.4768915374551
        ]
      }, 
      "properties" : {
        "Location" : "4115", 
        "LatestValue" : "7.207", 
        "LatestTime" : "05/02/2016 14:00", 
        "NameEN" : "Penybont", 
        "NameCY" : "Pen-y-bont", 
        "NGR" : "SS8767176568", 
        "ParamNameEN" : "RiverLevel", 
        "ParamNameCY" : "Lefel yr afon", 
        "StatusEN" : "Offline", 
        "StatusCY" : "All-lein", 
        "TitleEN" : "Ogmore at Penybont", 
        "TitleCY" : "Afon Ogwr ym Mhen-y-bont", 
        "Units" : "m", 
        "url" : "http://rloi.naturalresources.wales/ViewDetails?station=4115"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -2.90645968746434, 51.7019809139542
        ]
      }, 
      "properties" : {
        "Location" : "4054", 
        "LatestValue" : "0.294", 
        "LatestTime" : "13/06/2016 14:00", 
        "NameEN" : "Usk Town", 
        "NameCY" : "Brynbuga", 
        "NGR" : "SO3745500748", 
        "ParamNameEN" : "RiverLevel", 
        "ParamNameCY" : "Lefel yr afon", 
        "StatusEN" : "Offline", 
        "StatusCY" : "All-lein", 
        "TitleEN" : "Usk at Usk Town", 
        "TitleCY" : "Llan-ffwyst ym Mrynbuga", 
        "Units" : "m", 
        "url" : "http://rloi.naturalresources.wales/ViewDetails?station=4054"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -3.34592371998524, 51.7087547487603
        ]
      }, 
      "properties" : {
        "Location" : "4064", 
        "LatestValue" : "0.275", 
        "LatestTime" : "13/06/2016 14:00", 
        "NameEN" : "Troedyrhiw", 
        "NameCY" : "Troed-y-rhiw", 
        "NGR" : "SO0710001970", 
        "ParamNameEN" : "RiverLevel", 
        "ParamNameCY" : "Lefel yr afon", 
        "StatusEN" : "Online", 
        "StatusCY" : "Ar-lein", 
        "TitleEN" : "Taff at Troedyrhiw", 
        "TitleCY" : "Afon Taf yn Nhroed-y-rhiw", 
        "Units" : "m", 
        "url" : "http://rloi.naturalresources.wales/ViewDetails?station=4064"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -3.20988534441, 51.4973099653968
        ]
      }, 
      "properties" : {
        "Location" : "4067", 
        "LatestValue" : "0.633", 
        "LatestTime" : "13/06/2016 14:00", 
        "NameEN" : "Western Avenue", 
        "NameCY" : "Rhodfa'r Gorllewin", 
        "NGR" : "ST1611078290", 
        "ParamNameEN" : "RiverLevel", 
        "ParamNameCY" : "Lefel yr afon", 
        "StatusEN" : "Online", 
        "StatusCY" : "Ar-lein", 
        "TitleEN" : "Taff at Western Avenue", 
        "TitleCY" : "Afon Taf ger Rhodfa'r Gorllewin", 
        "Units" : "m", 
        "url" : "http://rloi.naturalresources.wales/ViewDetails?station=4067"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -3.38762194366533, 51.7517894456581
        ]
      }, 
      "properties" : {
        "Location" : "4072", 
        "LatestValue" : "0.281", 
        "LatestTime" : "13/06/2016 14:00", 
        "NameEN" : "Merthyr Tydfil", 
        "NameCY" : "Merthyr Tudful", 
        "NGR" : "SO0431006810", 
        "ParamNameEN" : "RiverLevel", 
        "ParamNameCY" : "Lefel yr afon", 
        "StatusEN" : "Online", 
        "StatusCY" : "Ar-lein", 
        "TitleEN" : "Taff at Merthyr Tydfil", 
        "TitleCY" : "Afon Taf ym Merthyr Tudful", 
        "Units" : "m", 
        "url" : "http://rloi.naturalresources.wales/ViewDetails?station=4072"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -3.29210971472949, 51.5749950955312
        ]
      }, 
      "properties" : {
        "Location" : "4219", 
        "LatestValue" : "0.372", 
        "LatestTime" : "13/06/2016 14:00", 
        "NameEN" : "Upper Boat Bridge", 
        "NameCY" : "Pont Glan-bad", 
        "NGR" : "ST1055587027", 
        "ParamNameEN" : "RiverLevel", 
        "ParamNameCY" : "Lefel yr afon", 
        "StatusEN" : "Online", 
        "StatusCY" : "Ar-lein", 
        "TitleEN" : "Taff at Upper Boat Bridge", 
        "TitleCY" : "Afon Taf ym Mhont Glan-bad", 
        "Units" : "m", 
        "url" : "http://rloi.naturalresources.wales/ViewDetails?station=4219"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -3.33796098908586, 51.6051254957445
        ]
      }, 
      "properties" : {
        "Location" : "4220", 
        "LatestValue" : "0.332", 
        "LatestTime" : "13/06/2016 14:00", 
        "NameEN" : "Pontypridd, Sion Street", 
        "NameCY" : "Pontypridd, Stryd Sion", 
        "NGR" : "ST0743990435", 
        "ParamNameEN" : "RiverLevel", 
        "ParamNameCY" : "Lefel yr afon", 
        "StatusEN" : "Online", 
        "StatusCY" : "Ar-lein", 
        "TitleEN" : "Taff at Pontypridd, Sion Street", 
        "TitleCY" : "Afon Taf ym Mhontypridd, Stryd Sion", 
        "Units" : "m", 
        "url" : "http://rloi.naturalresources.wales/ViewDetails?station=4220"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -3.68339548417901, 51.8261537326102
        ]
      }, 
      "properties" : {
        "Location" : "4091", 
        "LatestValue" : "0.405", 
        "LatestTime" : "13/06/2016 14:00", 
        "NameEN" : "Craig y Nos", 
        "NameCY" : "Craig y Nos", 
        "NGR" : "SN8408515510", 
        "ParamNameEN" : "RiverLevel", 
        "ParamNameCY" : "Lefel yr afon", 
        "StatusEN" : "Online", 
        "StatusCY" : "Ar-lein", 
        "TitleEN" : "Tawe at Craig y Nos", 
        "TitleCY" : "Afon Tawe yn Nghraig y Nos", 
        "Units" : "m", 
        "url" : "http://rloi.naturalresources.wales/ViewDetails?station=4091"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -3.93251625788289, 51.6421888498167
        ]
      }, 
      "properties" : {
        "Location" : "4111", 
        "LatestValue" : "3.239", 
        "LatestTime" : "13/06/2016 14:00", 
        "NameEN" : "Morfa", 
        "NameCY" : "Afon Morfa", 
        "NGR" : "SS6637695478", 
        "ParamNameEN" : "RiverLevel", 
        "ParamNameCY" : "Lefel yr afon", 
        "StatusEN" : "Online", 
        "StatusCY" : "Ar-lein", 
        "TitleEN" : "Tawe at Morfa", 
        "TitleCY" : "Afon Tawe ym Morfa", 
        "Units" : "m", 
        "url" : "http://rloi.naturalresources.wales/ViewDetails?station=4111"
      }
    }
  ]
}

Code samples

@ECHO OFF

curl -v -X GET "https://api.naturalresources.wales/riverlevels/v1/all"
-H "Ocp-Apim-Subscription-Key: {subscription key}"

--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");

            var uri = "https://api.naturalresources.wales/riverlevels/v1/all?" + queryString;

            var response = await client.GetAsync(uri);
        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();

        try
        {
            URIBuilder builder = new URIBuilder("https://api.naturalresources.wales/riverlevels/v1/all");


            URI uri = builder.build();
            HttpGet request = new HttpGet(uri);
            request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");


            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);

            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();

            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}

<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>

<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
            url: "https://api.naturalresources.wales/riverlevels/v1/all?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
            },
            type: "GET",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"https://api.naturalresources.wales/riverlevels/v1/all";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];

    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"GET"];
    // Request headers
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];

    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];

    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';

$request = new Http_Request2('https://api.naturalresources.wales/riverlevels/v1/all');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
);

$request->setHeader($headers);

$parameters = array(
    // Request parameters
);

$url->setQueryVariables($parameters);

$request->setMethod(HTTP_Request2::METHOD_GET);

// Request body
$request->setBody("{body}");

try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

headers = {
    # Request headers
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.urlencode({
})

try:
    conn = httplib.HTTPSConnection('api.naturalresources.wales')
    conn.request("GET", "/riverlevels/v1/all?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

headers = {
    # Request headers
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.parse.urlencode({
})

try:
    conn = http.client.HTTPSConnection('api.naturalresources.wales')
    conn.request("GET", "/riverlevels/v1/all?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://api.naturalresources.wales/riverlevels/v1/all')

request = Net::HTTP::Get.new(uri.request_uri)
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"

response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body