The German „Environmental Protection Agency“ (Umweltbundesamt) provides air quality data for Germany on its webpage and it is also possible to download data as CSV. However, as far as I know, there is no option to programmatically download these data, e.g. via an API. Does anyone know about a source for German air quality data which can be accessed programmatically, e.g via an API?
1 Answer
Although it's not documented, when clicking on a link for a CSV, I noticed that you can use the endpoint as your own API.
https://www.umweltbundesamt.de/api/air_data/v2/airquality/csv?date_from=2020-03-25&time_from=1&date_to=2020-04-01&time_to=24&station=1457&lang=de
So if we deconstruct the URL, we can create filters to pass to the web server, which will return a CSV. That's an API.
date_from=2020-03-25
date_to=2020-04-01
time_to=24
station=1457
To programmatically access this API, you would have your code pass variables to the endpoint and collect the results.
I also noticed that you can replace csv
with json
in the URL to get a JSON response
https://www.umweltbundesamt.de/api/air_data/v2/airquality/json?date_from=2020-03-25&time_from=1&date_to=2020-04-01&time_to=24&station=1457&lang=de
To get the metadata:
The file that is returned Luftqualitaet_DERP020_Trier-Ostallee_2020-03-25_00-2020-04-01_06.csv
contains some basic metadata in the filename.
To get an actual file of metadata, To get the metadata, I had to go to the Network view of "Developer Tools"
https://www.umweltbundesamt.de/daten/luft/luftdaten/stationen
The URL of the JSON metadata seems to be:
-
1
-
-
Well, sure. However, given the huge public interest in air quality issues in Germany, I would have expected a more "open data" like approach by the Umweltbundesamt. Anyway, I'll get this working via the URL. Thanks again.– PeterCommented Apr 1, 2020 at 9:54
-
It's even got
api
in the URL, so mild reverse engineering is best practice, right?– ojdoCommented May 15, 2020 at 12:03