Skip to content

Using the web API

madmagic007 edited this page Jan 29, 2025 · 7 revisions

Config

Configure the web API by editing the default config: plugins/RaveVisuals/config.yml.
Default config is as follows:

api:
    enabled: false
    port: 16522
    useAuthorization: false
    authorizationToken: ""
Key Type Possible values Description
enabled boolean true or false Enable or disable the web API
port integer Any possible port The port the web API will listen to
useAuthorization boolean true or false If false, the web API will NOT check for auth token. If set true the API will check for auth token
authorizationToken string any string the auth token the API will check for

After making any changes, reload the plugin with /sv reload. This will restart the web API with the new settings.

Authorization

When useAuthorization is set to true, the web API will refuse any connection that does not have the authorirization header set in the request.
If set to false, the API will allow any request.

Run /sv generateNewAuthorizationToken to generate a new random, 16 character alphanumeric auth token. This automatically updates the config. Copy it from there to use for any future requests. You can also manually define any string as an auth token in the config file. Make sure to reload the plugin with /sv reload to update the web API to check for the new auth token.

Endpoints

/set

Applies states to given fixtures or groups, post JSON object as following examples:

{
    "targetFixtures": [
        "left",
        "right"
    ],
    "targetGroups": [
        "backRow"
    ],
    "state": {
        "enable": true,
        "effect": "guardian",
        "rotation": "-180 45",
        "particle": "dust",
        "shape": "line",
        "color": "#0071FD",
        "sequence": "coolSequence"
    }
}

or

{
    "targetGroups": [
        "leftSide",
        "rightSide"
    ],
    "state": "awesomeStateExample"
}
Key Type Possible values Description
fixtureNames JSON string array Any fixture names The targeted fixtures, optional
groupNames JSON string array Any group names The targeted groups, optional
state String or JSON object State name or state JSON object Read below

State field:

The state field can either be a JSON object, in this case, the content of the JSON object can be any value(s) from states, formatted as JSON content.
Alternatively, the state field can be a string, in this case it should be the name of a defined state from states.yml config file.

/setvar

Change the value of vars, post JSON object as following example:

{
    "varA": 2,  
    "varB": 6.8,
    "exampleVar": "exampleOtherVar"
}

Each key of the JSON object is the name of the var to be changed. If the var does not exist, this key will be ignored.
You can put as many keys as you want. Each listed key will be checked one by one.
You can also fill the name of a different var for the value, like the /rv var set command, it will update the value once, it will not be a permanent reference.
Keep in mind, JSON objects have no defined order. The order of var updates is unpredictable. This means, if you have defined 'varA' as 2 in the config, and set the value of 'varA' to 5 with the api, and in the same post request set 'varB' to 'varA', theres a 50/50 chance that 'varB' might be either 2 or 5.

/commands

Run any minecraft/plugin commands or command sequences defined in commands.yml. Post JSON array as following example:

[
    "say this is a command ran from the web API",
    "rv scene start examplescene",
    "allbulbson"
]

Each entry of the JSON array should be a string.
First will be checked if each command entry is the exact name of a command defined in commands.yml and run those. If not, then it will try to run it as a command as is.

/scene

Start or stop scenes. Post JSON object as following example:

{
    "start": [
        "sceneNameToStart"
    ],
    "stop": [
        "sceneNameToStop"
    ]
}
Key Type Possible values Description
start JSON string array Any scene name Scenes to start, optional
stop JSON string array Any scene name Scenes to stop, optional

Clone this wiki locally