3

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?

enter image description here

1

1 Answer 1

3

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:

https://www.umweltbundesamt.de/api/air_data/v2/meta/json?use=measure&date_from=2020-01-01&time_from=1&date_to=2020-12-31&time_to=24&lang=de

enter image description here

4
  • 1
    Very good solution! Thx
    – Peter
    Commented Apr 1, 2020 at 8:09
  • “Everything is an API if you are stubborn enough”
    – philshem
    Commented Apr 1, 2020 at 8:49
  • 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.
    – Peter
    Commented Apr 1, 2020 at 9:54
  • It's even got api in the URL, so mild reverse engineering is best practice, right?
    – ojdo
    Commented May 15, 2020 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.