{
  "openapi": "3.1.0",
  "info": {
    "title": "Trinkwassermonitor Wasserqualitäts-API",
    "version": "v1",
    "description": "Geprüfte Trinkwasserwerte aus den veröffentlichten Prüfberichten der Wasserversorger, je Wert mit Quelle, Messdatum, Grenzwert und Rechtsgrundlage. Keine geschätzten Werte: Was ein Bericht nicht nennt, wird als „nicht im Bericht“ geliefert. Werte gelten ab Wasserwerk, nicht für die Hausinstallation.",
    "contact": {
      "name": "Trinkwassermonitor",
      "email": "info@trinkwassermonitor.ink",
      "url": "https://trinkwassermonitor.ink/"
    },
    "license": {
      "name": "Zitierhinweise",
      "url": "https://trinkwassermonitor.ink/.well-known/citation-policy.json"
    }
  },
  "externalDocs": {
    "description": "Methodik",
    "url": "https://trinkwassermonitor.ink/methodik/"
  },
  "servers": [
    {
      "url": "https://trinkwassermonitor.ink"
    }
  ],
  "paths": {
    "/api/v1/location": {
      "get": {
        "operationId": "findLocation",
        "summary": "Ort oder PLZ suchen",
        "description": "Findet ausgewertete Orte zu einer Postleitzahl oder einem Ortsnamen.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "PLZ oder Ortsname",
            "schema": {
              "type": "string"
            },
            "example": "97070"
          }
        ],
        "responses": {
          "200": {
            "description": "Erfolg",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Parameter fehlt oder ist ungültig",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Nicht gefunden: kein ausgewerteter Prüfbericht",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/water": {
      "get": {
        "operationId": "getWaterQuality",
        "summary": "Wasserwerte für eine PLZ oder einen Ort",
        "description": "Die geprüften Werte des zuständigen Versorgers mit Messdatum und Quelle.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "PLZ oder Ortsname",
            "schema": {
              "type": "string"
            },
            "example": "Würzburg"
          },
          {
            "name": "city",
            "in": "query",
            "required": false,
            "description": "Slug des Orts (alternativ zu q)",
            "schema": {
              "type": "string"
            },
            "example": "wuerzburg"
          }
        ],
        "responses": {
          "200": {
            "description": "Erfolg",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Parameter fehlt oder ist ungültig",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Nicht gefunden: kein ausgewerteter Prüfbericht",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/nearby": {
      "get": {
        "operationId": "findNearby",
        "summary": "Orte in der Nähe von Koordinaten",
        "description": "Ausgewertete Orte nahe einer Position.",
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "required": true,
            "description": "Breitengrad",
            "schema": {
              "type": "string"
            },
            "example": "49.79"
          },
          {
            "name": "lon",
            "in": "query",
            "required": true,
            "description": "Längengrad",
            "schema": {
              "type": "string"
            },
            "example": "9.95"
          }
        ],
        "responses": {
          "200": {
            "description": "Erfolg",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Parameter fehlt oder ist ungültig",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Nicht gefunden: kein ausgewerteter Prüfbericht",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/nearest": {
      "get": {
        "operationId": "findNearest",
        "summary": "Nächster ausgewerteter Ort zu einer PLZ",
        "description": "Für PLZ ohne eigenen Bericht: der nächste ausgewertete Ort (nicht dessen Werte übertragen).",
        "parameters": [
          {
            "name": "plz",
            "in": "query",
            "required": true,
            "description": "Fünfstellige PLZ",
            "schema": {
              "type": "string"
            },
            "example": "26506"
          }
        ],
        "responses": {
          "200": {
            "description": "Erfolg",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Parameter fehlt oder ist ungültig",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Nicht gefunden: kein ausgewerteter Prüfbericht",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/evidence": {
      "get": {
        "operationId": "getEvidence",
        "summary": "Beleg-Objekte je Wert",
        "description": "Jeder Wert eines Orts als zitierfähiges Beleg-Objekt (Quelle mit SHA-256, Messdatum, Grenzwert, Rechtsgrundlage, Status gemessen / unter der Nachweisgrenze / nicht im Bericht). Mit id: genau dieser Beleg, auch nach einem neueren Bericht.",
        "parameters": [
          {
            "name": "city",
            "in": "query",
            "required": false,
            "description": "Slug des Orts",
            "schema": {
              "type": "string"
            },
            "example": "wuerzburg"
          },
          {
            "name": "substance",
            "in": "query",
            "required": false,
            "description": "Stoffschlüssel, z. B. nitrat, pfas, blei",
            "schema": {
              "type": "string"
            },
            "example": "nitrat"
          },
          {
            "name": "id",
            "in": "query",
            "required": false,
            "description": "Beleg-ID (statt city)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Erfolg",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Parameter fehlt oder ist ungültig",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Nicht gefunden: kein ausgewerteter Prüfbericht",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/verify": {
      "get": {
        "operationId": "verifyClaim",
        "summary": "Eine Aussage gegenprüfen",
        "description": "Prüft, ob ein genannter Wert zum neuesten Prüfbericht passt: stimmt, veraltet, falsch oder nicht belegbar.",
        "parameters": [
          {
            "name": "city",
            "in": "query",
            "required": true,
            "description": "Slug des Orts",
            "schema": {
              "type": "string"
            },
            "example": "wuerzburg"
          },
          {
            "name": "substance",
            "in": "query",
            "required": true,
            "description": "Stoffschlüssel",
            "schema": {
              "type": "string"
            },
            "example": "nitrat"
          },
          {
            "name": "value",
            "in": "query",
            "required": true,
            "description": "Behaupteter Wert",
            "schema": {
              "type": "string"
            },
            "example": "27"
          },
          {
            "name": "unit",
            "in": "query",
            "required": false,
            "description": "Einheit: mg/l, µg/l, ng/l oder °dH",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Erfolg",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Parameter fehlt oder ist ungültig",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Nicht gefunden: kein ausgewerteter Prüfbericht",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/gaps": {
      "get": {
        "operationId": "getDataGaps",
        "summary": "Lücken-Register",
        "description": "Je Stoff, wie viele ausgewertete Orte einen Wert nennen und wie viele nicht – samt Zitiersatz.",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": false,
            "description": "Bundesland-Slug, z. B. bayern",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "substance",
            "in": "query",
            "required": false,
            "description": "Stoffschlüssel",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Erfolg",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Parameter fehlt oder ist ungültig",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Nicht gefunden: kein ausgewerteter Prüfbericht",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/changes": {
      "get": {
        "operationId": "getChanges",
        "summary": "Änderungen zwischen Berichten",
        "description": "Wie sich Werte eines Orts von einem Bericht zum nächsten verändert haben.",
        "parameters": [
          {
            "name": "city",
            "in": "query",
            "required": false,
            "description": "Slug des Orts",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Erfolg",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Parameter fehlt oder ist ungültig",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Nicht gefunden: kein ausgewerteter Prüfbericht",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/substances": {
      "get": {
        "operationId": "listSubstances",
        "summary": "Alle Parameter",
        "description": "Stoffe mit Grenzwerten und Rechtsgrundlage.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Erfolg",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Parameter fehlt oder ist ungültig",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Nicht gefunden: kein ausgewerteter Prüfbericht",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/substances/{key}": {
      "get": {
        "operationId": "getSubstance",
        "summary": "Ein Parameter",
        "description": "Grenzwert, Einheit und Rechtsgrundlage eines Stoffs.",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "description": "Stoffschlüssel",
            "schema": {
              "type": "string"
            },
            "example": "uran"
          }
        ],
        "responses": {
          "200": {
            "description": "Erfolg",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Parameter fehlt oder ist ungültig",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Nicht gefunden: kein ausgewerteter Prüfbericht",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/site-stats": {
      "get": {
        "operationId": "getSiteStats",
        "summary": "Kennzahlen der Datenbasis",
        "description": "Wie viele Orte, Versorger und Werte ausgewertet sind.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Erfolg",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Parameter fehlt oder ist ungültig",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Nicht gefunden: kein ausgewerteter Prüfbericht",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  }
}