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.
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.
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 = "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())