> For the complete documentation index, see [llms.txt](https://cp2004.gitbook.io/ws281x-led-status/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cp2004.gitbook.io/ws281x-led-status/master/documentation/rest-api.md).

# REST API

Documentation for the plugin's API, which can be used to create custom controls etc. in other services.

The plugin implements a [SimpleAPI as provided by OctoPrint](https://docs.octoprint.org/en/devel/plugins/mixins.html#simpleapiplugin), which enables external access to the plugin's functionality.

It has a single endpoint, supporting a get request and posting a command.

## SimpleAPI Get

<mark style="color:blue;">`GET`</mark> `http://octopi.local/api/plugin/ws281x_led_status`

Get current state of the plugin, which includes the light status and the torch status.

#### Headers

| Name      | Type   | Description                |
| --------- | ------ | -------------------------- |
| X-Api-Key | string | A valid OctoPrint API key. |

{% tabs %}
{% tab title="200 Details of the plugin's current state" %}

```javascript
{
  "lights_on": false,
  "torch_on": false
}
```

{% endtab %}
{% endtabs %}

## SimpleAPI Command

<mark style="color:green;">`POST`</mark> `http://octopi.local/api/plugin/ws281x_led_status`

Send commands to the plugin, to make it do something.

#### Headers

| Name      | Type   | Description               |
| --------- | ------ | ------------------------- |
| X-Api-Key | string | A valid OctoPrint API key |

#### Request Body

| Name    | Type   | Description                                               |
| ------- | ------ | --------------------------------------------------------- |
| command | string | The command to be sent to the plugin. See commands below. |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "lights_on": false,
  "torch_on": false
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
See also the [SimpleApi docs](https://docs.octoprint.org/en/devel/plugins/mixins.html#octoprint.plugin.SimpleApiPlugin) for details about how the request should be structured.
{% endhint %}
