This repository has been archived by the owner on Apr 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 289
HTTP REST API
Tobias Blum edited this page Sep 27, 2018
·
13 revisions
[GET] /status HTTP/1.0
Gets the current light color as RGB HEX value.
Parameter:
Result: [application/json]
Light status as JSON
{
"mode": 5,
"delay_ms": 50,
"brightness": 128,
"color": [
0,
0,
0
]
}
[GET] /esp_status HTTP/1.0
Gets the current ESP8266 status (heap, GPIO, ...).
Parameter:
Result: [application/json]
ESP status as JSON
{
"heap": 31384,
"analog": 4,
"gpio": 28677
}
heap: Free heap memory in bytes.
analog: Value for A0.
gpio: All GPIO statuses.
[GET] /restart HTTP/1.0
Restarts the ESP8266.
Parameter:
Result: [text/plain]
restarting...
[GET] /reset_wlan HTTP/1.0
Resets WLAN settings and restarts the ESP8266.
Parameter:
Result: [text/plain]
Restarting into captive portal...
[GET] /start_config_ap HTTP/1.0
Start config AP.
Parameter:
Result: [text/plain]
Starting config AP ...
[GET] /upload HTTP/1.0
Shows minimal upload form.
Parameter:
Result: [text/html]
Minimal upload form.
[GET] /set_brightness HTTP/1.0
Sets the brightness to the given value.
Parameter:
p: Value from 0 (off) to 255 (full brightness)
c: Value from 0 (off) to 100 (full brightness)
Result: [application/json]
Status JSON(see /status)
[GET] /get_brightness HTTP/1.0
Gets the brightness as value.
Parameter:
Result: [text/plain]
Value from 0 to 100.
[GET] /get_speed HTTP/1.0
Gets the effect speed as value.
Parameter:
Result: [text/plain]
Value from 0 to 255.
[GET] /set_speed HTTP/1.0
Sets the effect speed as value.
Parameter:
d: Value from 0 (max slow) to 255 (full speed)
Result: [application/json]
Status JSON(see /status)
[GET] /get_switch HTTP/1.0
Gets the light status (switch on/off) as boolean value.
Parameter:
Result: [text/plain]
Value 0 or 1.
[GET] /get_color HTTP/1.0
Gets the current light color as RGB HEX value.
Parameter:
Result: [text/plain]
Value as HEX, e.g. 00FFFF.
[GET] /off HTTP/1.0
Turns all leds immedately off.
Parameter:
Result: [application/json]
Status JSON (see /status)
[GET] /<lightmode> HTTP/1.0
Note: Deprecated in v2, use /set_mode instead. Will be removed in future versions.
Where <lightmode> is one of the following:
- all (Turn all LEDs on in the given or previously set color.)
- wipe (Turn all LEDs on in the given or previously set color, with wipe effect.)
- rainbow (Starts rainbow effect.)
- rainbowCycle (Starts rainbow cycle effect.)
- theaterchase (Starts theaterchase effect in the given or previously set color.)
- theaterchaseRainbow (Starts theaterchase effect with changing colors.)
- tv (Starts TV simulator.)
Parameter:
r: Value for red (0-255)
g: Value for green (0-255)
b: Value for blue (0-255)
or:
rgb: Value for color as HEX RGB value, e.g. 04d2ff
d: Value for delay as ms (0-255)
Result: [application/json]
Status JSON (see /status)
[GET] /get_modes HTTP/1.0 (Version >= 2.0)
Gets the list of avilable animation modes as JSON.
Parameter:
Result: [application/json]
[
{
"mode": 0,
"name": "Static"
},
{
"mode": 1,
"name": "Blink"
},
{
"mode": 2,
"name": "Breath"
},
...
]
[GET] /set_mode HTTP/1.0
Activates the given animation mode.
Parameter:
m: Value for mode (0-n), see /get_modes for animation id
r: Value for red (0-255)
g: Value for green (0-255)
b: Value for blue (0-255)
or:
rgb: Value for color as HEX RGB value, e.g. 04d2ff
d: Value for delay as ms (0-255)
s: Value for speed (0-255)
c: Value for brightness (0-100)
or:
p: Value for brightness (0-255)
Result: [application/json]
Status JSON (see /status)
[GET] /list HTTP/1.0
Lists all files in a directory in a SPIFFS filesystem.
Parameter:
dir: Directory (e.g. /)
Result: [application/json]
[
{
"type": "file",
"name": "edit.htm.gz"
},
{
"type": "file",
"name": "graphs.js.gz"
},
{
"type": "file",
"name": "favicon.ico"
},
{
"type": "file",
"name": "index.htm"
}
]
Error:
[500] BAD ARGS (text/plain): No parameter given.
[PUT] /edit HTTP/1.0
Create new file
Parameter:
First parameter: Filename as full path, e.g. /test.htm
Result: [text/plain]
(empty)
Error:
[500] BAD ARGS (text/plain): No parameter given.
[500] BAD PATH (text/plain): Path not valid.
[500] FILE EXISTS (text/plain): File already exists.
[500] CREATE FAILED (text/plain): File creation error.
[DELETE] /edit HTTP/1.0
Delete file.
Parameter:
First parameter: Filename as full path, e.g. /test.htm
Result: [text/plain]
(empty)
Error:
[500] BAD ARGS (text/plain): No parameter given.
[500] BAD PATH (text/plain): Path not valid.
[404] FileNotFound (text/plain): File not found.
[POST] /edit HTTP/1.0
Upload file.
Parameter:
Multipart upload.
Result: [text/plain]
(empty)