API
If you’ve got an api key, you can use the following api to upload effects, update effects and set routes programmatically. (api keys can only be generated by rgb.ikdoeict.be administrators)
You can use the npm package if possible, otherwise, use the instructions below on how to request these things from the server manually.
All of the following endpoints start with https://rgb.ikdoeict.be.
Public endpoints
The following endpoints do not require authentication.
-
GET /api/effectGet all effects in JSON format.
-
GET /api/effect/:idGet information about an effect in JSON format.
- Replace
:idwith the id of an effect
- Replace
Authenticated endpoints
All of the following routes must be authenticated by setting the Authorization header to Bearer <yourtokenhere>
Note: only the routes that can be used with an api key are displayed here.
-
POST /api/effectVar/:varName/:valueSets a variable on the led controller
- Replace
:varNamewith the variable name in the currently uploaded program you wish to set. - Replace
:valuewith a numerical value to set in the variable.
- Replace
-
POST /api/effect/:id/build?upload=trueUploads effect with id to the led controller. This will automatically disable the effect carrousel.
- Replace
:idwith the effect id you wish to upload.
- Replace
-
POST /api/routeCreates a route from a to b with color and duration.
Make sure to add the
Content-Type: application/jsonheader and include the following body:{ "startLed": 0, "endLed": 100, "duration": 1, "r": 255, "g": 255, "b": 0 }startLed: the starting led to begin drawing the route lineendLed: the ending led to stop drawing at (can be lower than startLed to create a route in the opposite direction)duration: the amount of seconds to show the router: red value (0 -> 255)g: green value (0 -> 255)b: blue value (0 -> 255)
-
POST /api/roomRoute/:roomNumberCreates a route to a fixed room.
- Replace
:roomNumberwith the room number (0 -> 6).
- Replace
-
POST /api/effect/carrousel/:secondsEnables or disables the effect carrousel.
- Replace
:secondswith the interval to switch between favorite effects or use 0 to disable the carrousel.
- Replace
WebSockets
The websocket api is currently not documented, you’ll have to browse the source code yourself to understand it.
Examples
Using javascript to fetch
Set effect variable myVarName to 123:
fetch("https://rgb.ikdoeict.be/api/effectVar/myVarName/123", {
method: "POST",
headers: {
"Authorization": "Bearer <yourtokenhere>"
}
})
Get effect with id 1:
let effect = await fetch("https://rgb.ikdoeict.be/api/effect/1", { method: "GET" })
Create a purple route from led 10 to 20:
fetch("https://rgb.ikdoeict.be/api/effect/1", {
method: "POST",
headers: {
"Authorization": "Bearer <yourtokenhere>",
"Content-Type": "application/json"
},
body: {
startLed: 10,
endLed: 20,
duration: 10, // 10 seconds visible
r: 255,
g: 0,
b: 255
}
})
Using curl to fetch
Set effect variable myVarName to 123:
curl -H "Authorization: Bearer <yourtokenhere>" -X POST https://rgb.ikdoeict.be/api/effectVar/myVarName/123
Disable the effect carrousel:
curl -H "Authorization: Bearer <yourtokenhere>" -X POST https://rgb.ikdoeict.be/api/effect/carrousel/0
Upload effect 3 to the led controller:
curl -H "Authorization: Bearer <yourtokenhere>" -X POST https://rgb.ikdoeict.be/api/effect/3/build?upload=true
Setting a single or multiple leds
It is not directly possible to set a led directly via an api route. To achieve this you must first create a new effect and create some unset variables:
// (new effect created at https://rgb.ikdoeict.be/effects/mine)
byte red;
byte green;
byte blue;
r = red
g = green;
b = blue;
Then, upload this effect program to the led controller (either via the webapp or via the api route above).
When uploaded, the led strip should turn completely black, this is because the red, green and blue variables are initialized to zero on upload.
Now that the effect is active, you can set the red, green and blue variables using the /api/effectVar/:varName/:value route in the following ways. This change will be sent to the led controller and the ledstrip will change color.
- Set the
redvariable to255:POST /api/effectVar/red/255 - Set the
greenvariable to150:POST /api/effectVar/green/150 - Set the
bluevariable to0:POST /api/effectVar/blue/0