Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

HTTP REST API

Malik Mann edited this page Mar 8, 2019 · 13 revisions

Generic

[GET] /status HTTP/1.0

This returns a JSON containing the current mode, delay, brightness and color.

{
  "mode": 5,
  "delay_ms": 50,
  "brightness": 128,
  "color": [
    0,
    0,
    0
  ]
}

[GET] /esp_status HTTP/1.0

This returns a JSON containing the current status of the ESP8266 with following stats:

  • heap: Free heap memory in bytes.
  • analog: Value for A0.
  • gpio: All GPIO statuses.
{
  "heap": 31384,
  "analog": 4,
  "gpio": 28677
}

[GET] /restart HTTP/1.0

Through this API endpoint you can resart your ESP.

Warning! This request returns a simple plain text answer!

restarting...

[GET] /reset_wlan HTTP/1.0

Resets WLAN settings and restarts the ESP8266.

Warning! This request returns a simple plain text answer!

Restarting into captive portal...

[GET] /start_config_ap HTTP/1.0

Start the config AP.

Warning! This request returns a simple plain text answer!

Starting config AP ...

Light control

[GET] /set_brightness HTTP/1.0

Sets the brightness to the given value.

Parameters

Only use one of the two possible parameters!

p: Value from 0 (off) to 255 (full brightness)
c: Value from 0 (off) to 100 (full brightness)

Response

This returns the full [GET] /status JSON

{
  "mode": 5,
  "delay_ms": 50,
  "brightness": 128,
  "color": [
    0,
    0,
    0
  ]
}

[GET] /get_brightness HTTP/1.0

Returns the brightness value.

Warning! This request returns a simple plain text answer!

A value from 0 to 100.

[GET] /set_speed HTTP/1.0

Sets the effect speed to the given value.

Parameters

d: Value from 0 (max slow) to 255 (full speed)

Response

This returns the full [GET] /status JSON

{
  "mode": 5,
  "delay_ms": 50,
  "brightness": 128,
  "color": [
    0,
    0,
    0
  ]
}

[GET] /get_speed HTTP/1.0

Gets the effect speed as value.

Warning! This request returns a simple plain text answer!

A value from 0 to 255.

[GET] /get_switch HTTP/1.0

Gets the light status (switch on/off) as boolean value.

Warning! This request returns a simple plain text boolean answer!

0 or 1.

[GET] /get_color HTTP/1.0

Gets the current light color as RGB HEX value.

Warning! This request returns a simple plain text answer!

Value as hex WITHOUT the leading '#' , e.g. 00FFFF.

[GET] /off HTTP/1.0

Turns all leds immedately off.

This returns the full [GET] /status JSON

{
  "mode": 5,
  "delay_ms": 50,
  "brightness": 128,
  "color": [
    0,
    0,
    0
  ]
}

[GET] /<lightmode> HTTP/1.0

Note: Deprecated in v2, use /set_mode instead. Will be removed in future versions.

Sets the lightmode where <lightmode> is one of the following:

Lightmode Desciption
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.

Parameters

Give either the red, green and blue value separate (as an integer ranging from 0 to 255) or give as a single RGB hex value

r: Value for red (0-255)
g: Value for green (0-255)
b: Value for blue (0-255)
d: Value for delay as ms (0-255)
rgb: Value for color as HEX RGB value, e.g. 04d2ff
d: Value for delay as ms (0-255)

Response

This returns the full [GET] /status JSON

{
  "mode": 5,
  "delay_ms": 50,
  "brightness": 128,
  "color": [
    0,
    0,
    0
  ]
}

[GET] /pixelconf HTTP/1.0

Change LED settings on the fly

Parameters

ct: Number of pixels (number)
rgbo: RGB Pixel Order (grb/gbr/rgb/rbg/brg/bgr)
pin: GPIO PIN for data line (16/5/4/0/2/14/12/13/15/3/1)

Response

{
  "pixel_count": 24,
  "rgb_order": 52,
  "pin": 14
}

[GET] /get_modes HTTP/1.0 (Version >= 2.0)

Returns the list of available animation modes as JSON.

[
  {
    "mode": 0,
    "name": "Static"
  },
  {
    "mode": 1,
    "name": "Blink"
  },
  {
    "mode": 2,
    "name": "Breath"
  },
  ...
]

[GET] /set_mode HTTP/1.0

Activates the given animation mode.

Parameters

m: Animation ID (see /get_modes for a list of all IDs)

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


c: Value for brightness (0-100)
OR
p: Value for brightness (0-255)


s: Value for speed (0-255)

Response

This returns the full [GET] /status JSON

{
  "mode": 5,
  "delay_ms": 50,
  "brightness": 128,
  "color": [
    0,
    0,
    0
  ]
}

SPIFFS webserver

[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)