Get Started with the KNMI Data Portal

Welcome to the information page of the KNMI Data Platform (KDP). Here you can find instructions and tips as well as the basics about the usage of the portal.

Retrieve data

In the KNMI Data Platform you can retrieve data via an API call. This can be achieved by following these steps:

  1. Pick a dataset from the KDP data catalogue.
  2. Copy the API endpoint for the dataset from the data catalogue using the copy button in the “API” column file_copy .
  3. Obtain an API key which authorizes requests to the API. See the section “Obtain an API key” for more information on what an API key is and how to obtain it.
  4. Make an API call to to retrieve a list of files. See the section “Make API calls” for more information on how to make API calls.
  5. Make an API call to to retrieve a specific file. See the section “Make API calls” for more information on how to make API calls.

Make API calls

Currently there are two API actions available:

The full documentation of these API endpoints can be found on the API Catalogue page. The correct endpoint for your dataset of choice can be found in the KDP data catalogue.

Below you can see some examples on how to make API call via the command line or via a Python script. The examples are written for the dataset “Actuele10mindataKNMIstations”.

Command line

Below are a few examples of using the API via a command line utility like curl:

Make sure that you replace <API_KEY> with a valid API key. See the “Obtain an API Key” section for information on how to obtain a public or a personal API key.

Programming

If a programming language has a HTTP library available, it can be used to access the API. Below are a few examples of calling the API using Python 3.
Make sure that you replace <API_KEY> with a valid API key. See the “Obtain an API Key” section for information on how to obtain a public or a personal API key.

  • Listing the first 10 files of today and retrieving the first one:
    from datetime import datetime
    import requests
    api_url = "https://api.dataplatform.knmi.nl/open-data"

    def main(): # Parameters api_key = "<API_KEY>" dataset_name = "Actuele10mindataKNMIstations" dataset_version = "2" max_keys = "10"
    # Use list files request to request first 10 files of the day. timestamp = datetime.utcnow().date().strftime("%Y%m%d") start_after_filename_prefix = f"KMDS__OPER_P___10M_OBS_L2_{timestamp}" list_files_response = requests.get(f"{api_url}/datasets/{dataset_name}/versions/{dataset_version}/files", headers={"Authorization": api_key}, params={"maxKeys": max_keys, "startAfterFilename": start_after_filename_prefix}) list_files = list_files_response.json() dataset_files = list_files.get("files")
    # Retrieve first file in the list files response filename = dataset_files[0].get("filename") get_file_response = requests.get(f"{api_url}/datasets/{dataset_name}/versions/{dataset_version}/files/{filename}/url" , headers={"Authorization": api_key}) download_url = get_file_response.json().get("temporaryDownloadUrl") dataset_file = requests.get(download_url)
    if __name__ == "__main__": main()
  • Retrieving the file from one hour ago:
    from datetime import datetime, timedelta
    import requests
    api_url = "https://api.dataplatform.knmi.nl/open-data"

    def main(): # Parameters api_key = "<API_KEY>" dataset_name = "Actuele10mindataKNMIstations" dataset_version = "2" max_keys = "10"
    # Use get file to retrieve a file from one hour ago. # Filename format for this dataset equals KMDS__OPER_P___10M_OBS_L2_YYYYMMDDHHMM.nc, where the minutes are increased in steps of 10. timestamp_now = datetime.utcnow() timestamp_one_hour_ago = timestamp_now - timedelta(hours=1) - timedelta(minutes=timestamp_now.minute % 10) filename = f"KMDS__OPER_P___10M_OBS_L2_{timestamp_one_hour_ago.strftime('%Y%m%d%H%M')}.nc" get_file_response = requests.get(f"{api_url}/datasets/{dataset_name}/versions/{dataset_version}/files/{filename}/url" , headers={"Authorization": api_key}) download_url = get_file_response.json().get("temporaryDownloadUrl") dataset_file = requests.get(download_url)
    if __name__ == "__main__": main()

Obtain an API key

An API key grants access to an API. Within the KDP, we have two types of API keys: keys for anonymous, unregistered users and keys for registered users. Below both key types and their advantages and disadvantages are described.

Anonymous keys

These API keys are used to get unregistered access to the Open Data. To ensure fair usage and to be able to scale the operation costs of the KDP, an upper limit of requests is set per API key. In the table below the access and limits are shown. Be aware that these limits are shared across all anonymous users of this API key.

For each key we also list until which date it is valid. We will update this page before that date to either extend or rotate the key, so keep an eye out for changes to this page

Anonymous
Operational API Key Access Rate Limit Quota
Available till 25 May 2021
5e554e19274a9600012a3eb1b626f95624124cf89e9b5d74c3304520
Open Data 50 requests per minute 3000 requests per hour

Registered keys

To use these keys, you have to register in this portal. Though you are not anonymous anymore, there are advantages to use these keys. There is no time limit to these API keys, so the applications that use those keys do not have to be updated yearly. Furthermore, the limits and quotas are not shared among all (anonymous) users.

To register for a key, follow these steps:

  • Create an account: In the navigation bar you can register to our portal. You get a confirmation e-mail with all your details.
  • Get an application key: The developer needs to requests an API key from the developer portal for selected API from the API Catalogue page. The key is intended for your use only, so keep it private. You can register for multiple APIs.
  • Check our own usage: You have your own developer dashboard. You can go to the developer dashboard, where you can view the API usage and limits for your API keys over the past 7 days.

The table below describe the rate limits and quotas for different APIs. Not all datasets in the Open Data API work well with the globally defined quotas. Therefore, specialized APIs are present that allow for customized quotas for a specific dataset. An API key for a specialized API is only valid for the dataset (and its path) mentioned in the API. You can request separate API keys for all these APIs.

Registered
Access Rate Limit Quota
Open Data 200 requests per hour 200 requests per hour
Open Data - Current 10 Minute Data KNMI Stations 50 requests per hour 50 requests per hour
Open Data - Radar Reflectivity Composites Policy 100 requests per hour 100 requests per hour
Customized user plan: Send an e-mail to dataservices@knmi.nl for a temporary personalized rate limit and quota

Tips and Tricks

Listing files

Currently it is not possible to order or filter the list of files in a dataset. Luckily, the naming convention of the files is predictable. Consequently, you can retrieve the list of files once to determine the naming convention and then use this convention in your scripts to retrieve the files.

Downloading a complete dataset

If you want to download a complete dataset it can take quite some time due to the rate limits and quotas associated with the API keys. Therefore we recommend sending an e-mail to dataservices@knmi.nl for temporarily personalized rate limit and quota. Please describe what you need and why you need it.

Questions?

If you have questions that are not answered here, or have suggestions for missed features, you could mail to dataservices@knmi.nl for more information.

Navigation