Skip to main content

Quickstart

Environmental data of the Federal Office for the Environment (FOEN) are open data (Open Data / OGD), publicly and freely available via this platform. The data can be queried through an API and integrated into your own applications. For individual datasets, the data is also offered as prepared files for download.

API

The FOEN has numerous datasets that are published successively on this platform. So that the interface does not have to be adapted with every new publication, the platform relies on GraphQL. The API takes a GraphQL query and returns the response as JSON. It is served at https://data.bafu.admin.ch/api.

Example – Query

The following query returns one active monitoring station from the hydrological network:

curl -X POST https://data.bafu.admin.ch/api \
-H "Content-Type: application/json" \
--data '{"query":"{ water { observations { stations(where:{status:{_eq:\"Aufgebaut\"}}, limit: 1) { no name riverName } } } }"}'

Example – Response

A response with HTTP status 200 and a JSON data field indicates that the endpoint is reachable and the query was valid.

{
"data": {
"water": {
"observations": {
"stations": [
{
"no": "2009",
"name": "Aare – Brienzwiler",
"riverName": "Aare"
}
]
}
}
}
}

Datasets

A list of all datasets with runnable example queries is available under Datasets. The full schema, including all namespaces, types and fields, can be browsed interactively in the GraphiQL Explorer.

Further reading

  • Queries – Interactive access to the endpoint via the embedded GraphiQL Explorer.
  • Filters and operatorswhere argument syntax and supported comparison operators.
  • Pagination – Per-query row limit and iteration strategies for larger windows.
  • Python and curl – Example code for calling the endpoint.