diff --git a/.gitignore b/.gitignore index a6a29e9..f0695a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ .idea -/node_modules +webapp/node_modules climate-server diff --git a/docs.md b/docs.md index e69de29..b0f6c3c 100644 --- a/docs.md +++ b/docs.md @@ -0,0 +1,48 @@ +# Quick Documentation + +Available endpoints: + +- `GET /` + - Display the chart homepage, by default the chart will show the last 60 minutes, updating every 30 seconds. +- `GET /?show-minutes=120` + - Display the chart homepage, overriding the default 60 minutes to the desired number. +- `POST /` + - Submit a snapshot to the database in the format of the following example JSON: + + ```json + { + "time": "2020-11-13 22:20:44.651953", + "temp": 25.2, + "humidity": 65.4, + "co2": 450 + } + ``` +- `GET //data` + - Retrieve a json of data snapshots over the last 60 minutes in the following format: + + ```json + { + "snapshots": [ + { + "id": 8868, + "time": "2020-11-13 20:00:12", + "temp": 21.7, + "humidity": 57.3, + "co2": 958 + }, + { + "id": 8867, + "time": "2020-11-13 19:59:42", + "temp": 21.7, + "humidity": 57.3, + "co2": 957 + }, + // ... + ] + } + ``` + +- `GET //data/now` + - In the same format as above, retrieve the latest snapshot. +- `GET //data?since=2006-01-02T15:04:05Z` + - In the same format as above, retrieve all snapshots recorded since the given ISO date.