Link Search Menu Expand Document

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/effect

    Get all effects in JSON format.

  • GET /api/effect/:id

    Get information about an effect in JSON format.

    • Replace :id with the id of an effect

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/:value

    Sets a variable on the led controller

    • Replace :varName with the variable name in the currently uploaded program you wish to set.
    • Replace :value with a numerical value to set in the variable.
  • POST /api/effect/:id/build?upload=true

    Uploads effect with id to the led controller. This will automatically disable the effect carrousel.

    • Replace :id with the effect id you wish to upload.
  • POST /api/route

    Creates a route from a to b with color and duration.

    Make sure to add the Content-Type: application/json header 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 line
    • endLed: 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 route
    • r: red value (0 -> 255)
    • g: green value (0 -> 255)
    • b: blue value (0 -> 255)
  • POST /api/roomRoute/:roomNumber

    Creates a route to a fixed room.

    • Replace :roomNumber with the room number (0 -> 6).
  • POST /api/effect/carrousel/:seconds

    Enables or disables the effect carrousel.

    • Replace :seconds with the interval to switch between favorite effects or use 0 to disable the carrousel.

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 red variable to 255: POST /api/effectVar/red/255
  • Set the green variable to 150:POST /api/effectVar/green/150
  • Set the blue variable to 0: POST /api/effectVar/blue/0