EDR API

Welcome to the information page about the KNMI Enviromental Data Retrieval (EDR) API. This page is meant to get your started with the EDR API. Detailed technical documentation is also available.

  1. What is an EDR API
  2. Available collections in the KNMI EDR API
  3. How to use an EDR API
  4. Different types of responses and how to visualise them
  5. Detailed technical documentation
  6. Example script

What is an EDR API

The goal of an EDR API is to query environmental data in a spatio-temporal manner. This data can be queried using different query patterns. You can, for example, query the data at a position or in a spatial cube. The available query endpoints depend on the Collection you are querying.

The API contains Collections (a dataset, for example observations). Within a collection there are one or more Instances (a subtype of the Collection, e.g. unvalidated).

The EDR API adheres to the EDR API specification made by the Open Geospatial Consortium.

Available collections in the KNMI EDR API

The following datasets are currently available in the KNMI EDR API

Collection Instance Corresponding file based datasets
observations unvalidated (default) Actuele 10 minuten data, bewolkingsgegevens, neerslaggegevens, vochtigheid_en_temperatuur, weer_en_luchtdruk, windgegevens, zonneschijnduur_en_straling
Tg1 default Temperature - gridded daily mean temperature in the Netherlands
Tx1 default Temperature - gridded daily maximum temperature in the Netherlands
Tn1 default Temperature - gridded daily minimum temperature in the Netherlands
Rd1 default Precipitation - gridded daily precipitation sum in the Netherlands
Ev24 default Evaporation - gridded daily Makkink evaporation in the Netherlands
wins50 default WINS50 - wind at 10-600 meter height for the Netherlands from HARMONIE-AROME as daily files

More collections may be added in the future.

How to use the EDR API

  • To see which collections are available inside the EDR you can make use of the /collections endpoint.
  • To get information about a specific collection you can use the /collections/{collection_name} endpoint.
  • To get information about the instances in a collection you can use the /collections/{collection_name}/instances endpoint.
  • For querying the data endpoints you can use the endpoints under the “Collection data queries” and the “Instance data queries” sections of the detailed technical documentation.

Different types of responses and how to visualise them

The API response will be in the following formats (dependent on the endpoint): GeoJSON, Coveragejson or JSON.

CoverageJSON and GeoJSON are special types of JSON. Each have their own tools and libraries to process and visualise them.

GeoJSON

GeoJSON is a combination of a Well-Known-Text (WKT) geometry type and additional information about this geometry inside a properties field. There is an online tool to visualize GeoJSON.

Example tools and libraries to work with GeoJSON in your own application:

CoverageJSON

CoverageJSON is a special type of JSON aimed at representing spatio-temporal data. It can be used to efficiently transfer parts of a big dataset to a client. It supports various types of geometries (called Domains). There is an online tool to visualize CoverageJSON.

Example tools and libraries to work with CoverageJSON:

Detailed technical documentation

The Open API Specification of the API, including examples, can be found in the detailed technical documentation.

Example script

import sys

import requests

collection = "observations"
base_url = f"https://api.dataplatform.knmi.nl/edr/collections/{collection}"
token = "<YOUR API KEY>"
headers = {"Authorization": token}


def metadata():
    r = requests.get(base_url, headers=headers)
    r.raise_for_status()
    return r.json()


def locations():
    r = requests.get(base_url + "/locations", headers=headers)
    r.raise_for_status()
    return r.json()


def position(params):
    r = requests.get(base_url + "/position", params, headers=headers)
    r.raise_for_status()
    return r.json()


def main():
    md = metadata()
    print(md["extent"]["temporal"]["interval"])

    locs = locations()
    print([f["properties"]["name"] for f in locs["features"]])

    params = {
        "coord": "POINT(5.14527777777778 51.8577777777778)",
        "datetime": "2022-07-19T06:00:00Z/2022-07-19T18:00:00Z",
        "parameter-name": "t_dryb_10",
    }
    print(position(params))


if __name__ == "__main__":
    sys.exit(main())

Navigation