Files
MSE-PI-E2EEDA-Plein-de-eeee…/db/src/docs/swagger.json

313 lines
10 KiB
JSON

{
"swagger": "2.0",
"info": {
"description": "This is a gateway API for IoT data.",
"title": "Gateway API",
"contact": {},
"version": "1.0"
},
"host": "api.db.e.kb28.ch",
"basePath": "/api/v1",
"paths": {
"/battery": {
"get": {
"security": [
{
"BasicAuth": []
}
],
"description": "Get the last battery level for each node grouped by room",
"produces": [
"application/json"
],
"tags": [
"battery"
],
"summary": "Get last battery level for each node",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": true
}
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/export/csv": {
"get": {
"security": [
{
"BasicAuth": []
}
],
"description": "Export CO2, temperature, humidity, window status and battery data for a node over a time range",
"produces": [
"text/csv"
],
"tags": [
"export"
],
"summary": "Export sensor data as CSV",
"parameters": [
{
"type": "string",
"description": "Node MAC address (e.g. E8:F3:0A:F7:3B:F3)",
"name": "node",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Start time in RFC3339 format (e.g. 2026-05-27T13:00:00Z)",
"name": "from",
"in": "query",
"required": true
},
{
"type": "string",
"description": "End time in RFC3339 format (e.g. 2026-05-27T15:00:00Z)",
"name": "to",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "CSV file",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/rooms": {
"get": {
"security": [
{
"BasicAuth": []
}
],
"description": "Get a list of all unique rooms from the measurement",
"produces": [
"application/json"
],
"tags": [
"rooms"
],
"summary": "Get all unique rooms",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/rooms/high-co2": {
"get": {
"security": [
{
"BasicAuth": []
}
],
"description": "Get a list of rooms where CO2 levels are above the threshold",
"produces": [
"application/json"
],
"tags": [
"rooms"
],
"summary": "Get rooms with high CO2 levels",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/rest.RoomCO2Status"
}
}
}
}
}
},
"/rooms/{room-id}/current": {
"get": {
"security": [
{
"BasicAuth": []
}
],
"description": "Get the latest record for a specific room",
"produces": [
"application/json"
],
"tags": [
"rooms"
],
"summary": "Get current data for a room",
"parameters": [
{
"type": "string",
"description": "Room ID",
"name": "room-id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": true
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/rooms/{room-id}/history": {
"get": {
"security": [
{
"BasicAuth": []
}
],
"description": "Get history for a specific room",
"produces": [
"application/json"
],
"tags": [
"rooms"
],
"summary": "Get history for a room",
"parameters": [
{
"type": "string",
"description": "Room ID",
"name": "room-id",
"in": "path",
"required": true
},
{
"type": "string",
"default": "1 day",
"description": "Time window (e.g., 1 day, 1 hour, 30 min)",
"name": "window",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
}
},
"definitions": {
"rest.RoomCO2Status": {
"type": "object",
"properties": {
"co2": {
"type": "integer"
},
"is_high": {
"type": "boolean"
},
"room": {
"type": "string"
}
}
}
},
"securityDefinitions": {
"BasicAuth": {
"type": "basic"
}
}
}