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.
DISCLAIMER: This pre-release version is still in development. The API may contain bugs, and data integrity is not yet verified.
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
).
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 | 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 |
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.
Access | Rate Limit | Quota |
---|---|---|
EDR API | 200 requests per second | 1000 requests per hour |
How to use an EDR API
https://api.dataplatform.knmi.nl/edr/v1/collections
endpoint.https://api.dataplatform.knmi.nl/edr/v1/collections/{collection_name}
endpoint.https://api.dataplatform.knmi.nl/edr/v1/collections/{collection_name}/instances
endpoint.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 = "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(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 = {
"coords": "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())