|
|
## Routes overview
|
|
|
|
|
|
| Route | Description | Link |
|
|
|
| -------- | -------- | ---- |
|
|
|
| `/` | Root document, basic service information | [Root](#root) |
|
|
|
| `/states` | Get the current states of all relays | [Current States](#current-states) |
|
|
|
| `/states/[0-9]+` | Get the current state of a specific relay | [Current State](#current-state) |
|
|
|
| `/states/[0-9]+/on` | Set the a relay state to `on` | [Set State On](#set-state-on) |
|
|
|
| `/states/[0-9]+/off` | Set the a relay state to `off` | [Set State Off](#set-state-off) |
|
|
|
| `/states/[0-9]+/toggle` | Toggle a relay state | [Toggle State](#toggle-state) |
|
|
|
|
|
|
## Routes
|
|
|
|
|
|
* :info: All routes which change the state of the actor will return the new state of the actor
|
|
|
* :info: The API requires no authentication at all
|
|
|
|
|
|
### Root
|
|
|
|
|
|
* **Path**: `/`
|
|
|
* **Method**: `GET`
|
|
|
* **Status Codes**: \[200\]
|
|
|
|
|
|
#### Request
|
|
|
|
|
|
* [Try it](http://10.0.0.157:641/)
|
|
|
|
|
|
```http
|
|
|
GET / HTTP/1.1
|
|
|
Host: 10.0.0.157:641
|
|
|
Accept: */*
|
|
|
```
|
|
|
|
|
|
#### Response
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"name": "relayd",
|
|
|
"version": "0.1.1"
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### Current States
|
|
|
|
|
|
* **Path**: `/states`
|
|
|
* **Method**: `GET`
|
|
|
* **Status Codes**: \[200\]
|
|
|
|
|
|
#### Request
|
|
|
|
|
|
* [Try it](http://10.0.0.157:641/states)
|
|
|
|
|
|
```http
|
|
|
GET /states HTTP/1.1
|
|
|
Host: 10.0.0.157:641
|
|
|
Accept: */*
|
|
|
```
|
|
|
|
|
|
#### Response
|
|
|
|
|
|
```json
|
|
|
[
|
|
|
{
|
|
|
"id": 0,
|
|
|
"gpio": 25,
|
|
|
"state": true
|
|
|
},
|
|
|
{
|
|
|
"id": 1,
|
|
|
"gpio": 26,
|
|
|
"state": false
|
|
|
}
|
|
|
]
|
|
|
```
|
|
|
|
|
|
### Current State
|
|
|
|
|
|
* **Path**: `/states/[0-9]+`
|
|
|
* **Method**: `GET`
|
|
|
* **Status Codes**: \[200\]
|
|
|
|
|
|
#### Request
|
|
|
|
|
|
* [Try it](http://10.0.0.157:641/states/0)
|
|
|
|
|
|
```http
|
|
|
GET /states/0 HTTP/1.1
|
|
|
Host: 10.0.0.157:641
|
|
|
Accept: */*
|
|
|
```
|
|
|
|
|
|
#### Response
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"id": 0,
|
|
|
"gpio": 25,
|
|
|
"state": true
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### Set State On
|
|
|
|
|
|
* **Path**: `/states/[0-9]+/on`
|
|
|
* **Method**: `GET`
|
|
|
* **Status Codes**: \[200\]
|
|
|
|
|
|
#### Request
|
|
|
|
|
|
* [Try it](http://10.0.0.157:641/states/0/on)
|
|
|
|
|
|
```http
|
|
|
GET /states/0/on HTTP/1.1
|
|
|
Host: 10.0.0.157:641
|
|
|
Accept: */*
|
|
|
```
|
|
|
|
|
|
#### Response
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"id": 0,
|
|
|
"gpio": 25,
|
|
|
"state": true
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### Set State Off
|
|
|
|
|
|
* **Path**: `/states/[0-9]+/off`
|
|
|
* **Method**: `GET`
|
|
|
* **Status Codes**: \[200\]
|
|
|
|
|
|
#### Request
|
|
|
|
|
|
* [Try it](http://10.0.0.157:641/states/0/off)
|
|
|
|
|
|
```http
|
|
|
GET /states/0/off HTTP/1.1
|
|
|
Host: 10.0.0.157:641
|
|
|
Accept: */*
|
|
|
```
|
|
|
|
|
|
#### Response
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"id": 0,
|
|
|
"gpio": 25,
|
|
|
"state": false
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### Toggle State
|
|
|
|
|
|
* **Path**: `/states/[0-9]+/toggle`
|
|
|
* **Method**: `GET`
|
|
|
* **Status Codes**: \[200\]
|
|
|
|
|
|
#### Request
|
|
|
|
|
|
* [Try it](http://10.0.0.157:641/states/0/toggle)
|
|
|
|
|
|
```http
|
|
|
GET /states/0/toggle HTTP/1.1
|
|
|
Host: 10.0.0.157:641
|
|
|
Accept: */*
|
|
|
```
|
|
|
|
|
|
#### Response
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"id": 0,
|
|
|
"gpio": 25,
|
|
|
"state": true
|
|
|
}
|
|
|
``` |