EDR API


Welcome to the documentation page about the KNMI Enviromental Data Retrieval (EDR) API. This page is meant to get you started with the EDR API. The EDR API allows users to query datasets on specific parameters in a spatio-temporal manner, reducing the need to download entire datasets. The EDR API adheres to Open Geospatial Consortium - EDR standard, facilitating integration with other geospatial tools and systems.


More information on:

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 single position or in a spatial cube. You can also query a single datetime or an entire range. Typically, an EDR API uses CoverageJSON as output format for data queries.

An EDR API contains collections which can be thought of as datasets. The available query endpoints depend on the collection you are querying.

Available collections in the KNMI EDR API

The datasets in the table below are currently available in the KNMI EDR API. More collections may be added in the future.

Collection Corresponding file based datasets
observations (DEPRECATED) Actuele 10 minuten data, bewolkingsgegevens, neerslaggegevens, vochtigheid_en_temperatuur, weer_en_luchtdruk, windgegevens, zonneschijnduur_en_straling
10-minute-in-situ-meteorological-observations Near real-time 10-minute automated in-situ ground-based meteorological surface observations in the Netherlands
hourly-in-situ-meteorological-observations-validated Hourly and validated automated in-situ ground-based meteorological surface observations in the Netherlands
daily-in-situ-meteorological-observations-validated Daily and validated automated in-situ ground-based meteorological surface observations in the Netherlands
Tg1 Temperature - gridded daily mean temperature in the Netherlands
Tx1 Temperature - gridded daily maximum temperature in the Netherlands
Tn1 Temperature - gridded daily minimum temperature in the Netherlands
Rd1 Precipitation - gridded daily precipitation sum in the Netherlands
Ev24 Evaporation - gridded daily Makkink evaporation in the Netherlands
wins50 WINS50 - wind at 10-600 meter height for the Netherlands from HARMONIE-AROME as daily files

Obtaining an API token

Requesting an API token

In order to make API requests, you’ll need an API key for the EDR API. You can request an API key for the EDR API in the API Catalog. To request an API key, you will need to register for an account. You can do this by clicking the “Register” button in the top right corner of the page. Once registered, you can request an API key by clicking on the appropriate “Request API Key” button on the API Catalog page. You will receive an email with your API key.

The table below lists the rate limits and quotas for the API keys.

Registered
Access Rate Limit Quota
EDR API 200 requests per second 1000 requests per hour


How to use an EDR API

  • To see which collections are available inside the EDR you can make use of the https://api.dataplatform.knmi.nl/edr/v1/collections endpoint.
  • To get information about a specific collection you can use the https://api.dataplatform.knmi.nl/edr/v1/collections/{collection_name} endpoint.
  • To get information about the instances in a collection you can use the https://api.dataplatform.knmi.nl/edr/v1/collections/{collection_name}/instances endpoint.
  • For data queries you can use the endpoints listed in their respective collection 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:

Example script

import sys

import requests

api_version = "v1"
collection = "10-minute-in-situ-meteorological-observations"
base_url = f"https://api.dataplatform.knmi.nl/edr/{api_version}/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(f"{base_url}/locations", headers=headers)
    r.raise_for_status()
    return r.json()


def location(location_id, params):
    r = requests.get(f"{base_url}/locations/{location_id}", params, headers=headers)
    r.raise_for_status()
    return r.json()


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

    locs = locations()
    print([f"{f['id']} - {f['properties']['name']}" for f in locs["features"]])

    params = {
        "datetime": "2022-07-19T06:00:00Z/2022-07-19T18:00:00Z",
        "parameter-name": "ta,rh",
    }
    print(location("0-20000-0-06260", params))


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

Navigation