From 71cf5fc46ddcccd1fe745607ef4dfaff016de74a Mon Sep 17 00:00:00 2001 From: Mike Shoup Date: Wed, 3 Oct 2018 08:44:07 -0600 Subject: [PATCH] Add REST API documentation --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/README.md b/README.md index dc1ead1..2e4248e 100644 --- a/README.md +++ b/README.md @@ -56,3 +56,46 @@ nohup ./temp-gopher -c config.yml run & ``` Or use `systemctl` or some other process supervisor to run it. + +## REST API + +There is a very simple REST API for viewing the current configuration and status. The application launches and binds to `:8080`. + +To view the current status, query `http://:8080/api/status`: + +``` +$ curl -s http://localhost:8080/api/status | jq . +{ + "fermenter": { + "alias": "fermenter", + "temp": 19.812, + "cooling": false, + "heating": false, + "reading": "2018-10-03T08:43:05.795870992-06:00", + "changed": "2999-01-01T00:00:00Z" + } +} +``` + +To view the current configuration, query `http://:8080/api/config`: + +``` +$ curl -s http://localhost:8080/api/config | jq . +{ + "Sensors": [ + { + "id": "28-000008083108", + "alias": "fermenter", + "hightemp": 30, + "lowtemp": 27, + "heatgpio": 13, + "heatinvert": false, + "heatminutes": 1, + "coolgpio": 19, + "coolinvert": false, + "coolminutes": 4, + "verbose": false + } + ] +} +```