{
  "openapi": "3.1.0",
  "info": {
    "title": "HackTheRied – Public API",
    "version": "0.1.0",
    "description": "Public environmental sensor data. No authentication required. Start with GET /api/v1/sensors, then use a returned id for sensor_id or the station path parameter. Historical queries require start_time in ISO-8601 UTC format."
  },
  "servers": [
    {
      "url": "https://api.hack-the-ried.de"
    }
  ],
  "security": [],
  "paths": {
    "/api/v1/sensors": {
      "get": {
        "tags": [
          "Sensors Public"
        ],
        "summary": "List all publicly visible sensors",
        "description": "Returns all active, non-hidden sensor stations for public consumption.",
        "operationId": "list_public_sensors_api_v1_sensors_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/SensorMetadataResponse"
                  },
                  "type": "array",
                  "title": "Response List Public Sensors Api V1 Sensors Get"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/v1/sensors/{id}": {
      "get": {
        "tags": [
          "Sensors Public"
        ],
        "summary": "Get sensor metadata",
        "description": "Returns metadata for a specific public sensor.",
        "operationId": "get_public_sensor_api_v1_sensors__id__get",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SensorMetadataResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/v1/telemetry/raw": {
      "get": {
        "tags": [
          "Telemetry Public"
        ],
        "summary": "Get raw historical telemetry readings (Public)",
        "description": "Retrieves raw historical data points for a specific visible sensor over a time range.",
        "operationId": "get_raw_telemetry_api_v1_telemetry_raw_get",
        "parameters": [
          {
            "name": "sensor_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the sensor",
              "title": "Sensor Id"
            },
            "description": "The ID of the sensor"
          },
          {
            "name": "start_time",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Start timestamp (ISO 8601)",
              "title": "Start Time"
            },
            "description": "Start timestamp (ISO 8601)"
          },
          {
            "name": "end_time",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "End timestamp",
              "title": "End Time"
            },
            "description": "End timestamp"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 5000,
              "minimum": 1,
              "description": "Max points to return (1-5000)",
              "default": 100,
              "title": "Limit"
            },
            "description": "Max points to return (1-5000)"
          },
          {
            "name": "metric",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                },
                {
                  "type": "null"
                }
              ],
              "title": "Metric"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SensorReading"
                  },
                  "title": "Response Get Raw Telemetry Api V1 Telemetry Raw Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/v1/telemetry/aggregates": {
      "get": {
        "tags": [
          "Telemetry Public"
        ],
        "summary": "Get aggregated telemetry time buckets (Public)",
        "description": "Leverages TimescaleDB's native `time_bucket` to calculate min, max, average values \nand sample counts grouped into regular time intervals for visible sensors.",
        "operationId": "get_telemetry_aggregates_api_v1_telemetry_aggregates_get",
        "parameters": [
          {
            "name": "sensor_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the sensor",
              "title": "Sensor Id"
            },
            "description": "The ID of the sensor"
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Bucket interval (e.g. 15 minutes, 1 hour, 1 day)",
              "default": "1 hour",
              "title": "Interval"
            },
            "description": "Bucket interval (e.g. 15 minutes, 1 hour, 1 day)"
          },
          {
            "name": "start_time",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Start timestamp (ISO 8601)",
              "title": "Start Time"
            },
            "description": "Start timestamp (ISO 8601)"
          },
          {
            "name": "end_time",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "End timestamp",
              "title": "End Time"
            },
            "description": "End timestamp"
          },
          {
            "name": "metric",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                },
                {
                  "type": "null"
                }
              ],
              "title": "Metric"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SensorAggregateResponse"
                  },
                  "title": "Response Get Telemetry Aggregates Api V1 Telemetry Aggregates Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/v1/telemetry/latest": {
      "get": {
        "tags": [
          "Telemetry Public"
        ],
        "summary": "Get latest reading for sensor (Public)",
        "description": "Retrieves the single most recent data point for a given visible sensor.",
        "operationId": "get_latest_sensor_reading_api_v1_telemetry_latest_get",
        "parameters": [
          {
            "name": "sensor_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the sensor",
              "title": "Sensor Id"
            },
            "description": "The ID of the sensor"
          },
          {
            "name": "metric",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                },
                {
                  "type": "null"
                }
              ],
              "title": "Metric"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SensorReading"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/v1/telemetry/latest/metrics": {
      "get": {
        "tags": [
          "Telemetry Public"
        ],
        "summary": "Get the latest reading of each metric for a sensor (Public)",
        "operationId": "get_latest_sensor_metrics_api_v1_telemetry_latest_metrics_get",
        "parameters": [
          {
            "name": "sensor_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the sensor",
              "title": "Sensor Id"
            },
            "description": "The ID of the sensor"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SensorReading"
                  },
                  "title": "Response Get Latest Sensor Metrics Api V1 Telemetry Latest Metrics Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/v1/telemetry/latest/window": {
      "get": {
        "tags": [
          "Telemetry Public"
        ],
        "summary": "Get the latest locally aggregated sensor window",
        "operationId": "get_latest_sensor_window_api_v1_telemetry_latest_window_get",
        "parameters": [
          {
            "name": "sensor_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the sensor",
              "title": "Sensor Id"
            },
            "description": "The ID of the sensor"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/v1/archives": {
      "get": {
        "tags": [
          "Archives Public"
        ],
        "summary": "List public monthly data downloads",
        "description": "Monthly ZIP parts without the interactive API row limit. Download every\npart of a month for its full snapshot; late data may require a new version.\nSnapshots containing stations which became private are not listed.",
        "operationId": "list_archives_api_v1_archives_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/Archive"
                  },
                  "type": "array",
                  "title": "Response List Archives Api V1 Archives Get"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/v1/downloads": {
      "get": {
        "tags": [
          "Downloads Public"
        ],
        "summary": "Download related public CSV tables as ZIP",
        "operationId": "download_data_api_v1_downloads_get",
        "parameters": [
          {
            "name": "topic",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "all",
                "temperature",
                "mobility",
                "roadworks",
                "humidity",
                "precipitation",
                "water",
                "soil"
              ],
              "type": "string",
              "default": "all",
              "title": "Topic"
            }
          },
          {
            "name": "sample",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false,
              "title": "Sample"
            }
          },
          {
            "name": "start",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Start"
            }
          },
          {
            "name": "end",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ],
              "title": "End"
            }
          },
          {
            "name": "check",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false,
              "title": "Check"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/v1/map/sensors": {
      "get": {
        "tags": [
          "Telemetry Public"
        ],
        "summary": "Map Sensor Snapshot",
        "operationId": "map_sensor_snapshot_api_v1_map_sensors_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": []
      }
    }
  },
  "components": {
    "schemas": {
      "SensorMetadataResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Unique sensor ID generated by database"
          },
          "friendly_name": {
            "type": "string",
            "title": "Friendly Name"
          },
          "latitude": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Latitude"
          },
          "longitude": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Longitude"
          },
          "is_hidden": {
            "type": "boolean",
            "title": "Is Hidden",
            "default": false
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "friendly_name",
          "created_at"
        ],
        "title": "SensorMetadataResponse"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "SensorReading": {
        "properties": {
          "metric": {
            "type": "string",
            "maxLength": 64,
            "minLength": 1,
            "title": "Metric",
            "default": "value"
          },
          "sensor_id": {
            "type": "string",
            "title": "Sensor Id",
            "example": "temp-sensor-01"
          },
          "value": {
            "type": "number",
            "title": "Value",
            "example": 24.5
          },
          "unit": {
            "type": "string",
            "title": "Unit",
            "example": "celsius"
          },
          "timestamp": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Timestamp"
          }
        },
        "type": "object",
        "required": [
          "sensor_id",
          "value",
          "unit"
        ],
        "title": "SensorReading"
      },
      "SensorAggregateResponse": {
        "properties": {
          "metric": {
            "type": "string",
            "title": "Metric",
            "default": "value"
          },
          "bucket": {
            "type": "string",
            "format": "date-time",
            "title": "Bucket"
          },
          "avg_value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Avg Value"
          },
          "min_value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Min Value"
          },
          "max_value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Value"
          },
          "sample_count": {
            "type": "integer",
            "title": "Sample Count"
          },
          "unit": {
            "type": "string",
            "title": "Unit"
          }
        },
        "type": "object",
        "required": [
          "bucket",
          "avg_value",
          "min_value",
          "max_value",
          "sample_count",
          "unit"
        ],
        "title": "SensorAggregateResponse"
      },
      "Archive": {
        "properties": {
          "month": {
            "type": "string",
            "title": "Month"
          },
          "format_version": {
            "type": "integer",
            "title": "Format Version"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Generated At"
          },
          "is_complete": {
            "type": "boolean",
            "title": "Is Complete"
          },
          "reading_count": {
            "type": "integer",
            "title": "Reading Count"
          },
          "size_bytes": {
            "type": "integer",
            "title": "Size Bytes"
          },
          "files": {
            "items": {
              "$ref": "#/components/schemas/ArchiveFile"
            },
            "type": "array",
            "title": "Files"
          }
        },
        "type": "object",
        "required": [
          "month",
          "format_version",
          "generated_at",
          "is_complete",
          "reading_count",
          "size_bytes",
          "files"
        ],
        "title": "Archive"
      },
      "ArchiveFile": {
        "properties": {
          "filename": {
            "type": "string",
            "title": "Filename"
          },
          "url": {
            "type": "string",
            "title": "Url"
          },
          "size_bytes": {
            "type": "integer",
            "title": "Size Bytes"
          },
          "reading_count": {
            "type": "integer",
            "title": "Reading Count"
          },
          "sha256": {
            "type": "string",
            "title": "Sha256"
          }
        },
        "type": "object",
        "required": [
          "filename",
          "url",
          "size_bytes",
          "reading_count",
          "sha256"
        ],
        "title": "ArchiveFile"
      }
    }
  }
}