From c7edddca93f737bbf94e78476698c3ceb83f0d4a Mon Sep 17 00:00:00 2001 From: Siesta <124433727+siestaw@users.noreply.github.com> Date: Sun, 20 Jul 2025 18:18:23 +0200 Subject: [PATCH] feat: REST documentations --- README.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d72be6..da470ba 100644 --- a/README.md +++ b/README.md @@ -1 +1,64 @@ -# Laterna \ No newline at end of file +# Laterna + +## API Documentation + +### Base URL +`http://your-server.com/api/v1` + +--- +### Authentification +The admin token will be displayed once while starting for the first time. To generate a new one, run with the `--resetAdminToken` flag. + +All endpoints require the admin token in the header of the request: +``` +Authorization: +``` + +--- + +### Routes + +#### Controller +| Method | Route | Description | Request Body | +|---------|----------------------------|----------------------------------------|----------------------------------| +| GET | `/colors/{id}` | Get the current color of an controller | — | +| PUT | `/colors/{id}` | Set the color of an controller |`{ "ID": "1" }` | + +--- + +#### Colors +| Method | Route | Description | Request Body | +|---------|----------------------------|----------------------------------------|----------------------------------| +| GET | `/colors/{id}` | Get the current color of an controller | — | +| PUT | `/colors/{id}` | Set the color of an controller |`{ "color": "#FF0000" }` | + +--- + +### cURL examples + + +#### Create a new controller +```bash +$ curl -X POST http://your-server.com/api/v1/controllers \ + -H "Authorization: $TOKEN" +``` + +#### Delete an controller +```bash +$ curl -X DELETE localhost:8080/api/v1/controllers \ + -H "Authorization: $TOKEN" \ + -d '{"ID": 1}' +``` + + +#### Get the current color of an controller +```bash +$ curl -X GET localhost:8080/api/v1/colors/1 \ + -H "Authorization: $TOKEN" +``` +#### Set the color of an controller +```bash +$ curl -X PUT localhost:8080/api/v1/colors/1 \ + -H "Authorization:$TOKEN" \ + -d '{"Color": "#C2C342"}' +```