# WInFiDEL - Web API

WInFiDEL currently supports the following APIs that can be used to interact and/or integrate with other systems:

- Web API (this document)
- [SerialAPI](https://docs.sasakaranovic.com/winfidel/usb_api/index.md)

## WEB API Endpoints

### Read diameter information

URL: `/api/v0/diameter/read`

#### Response

Returns JSON data containing diameter information

```text
{
    "status":"ok",
    "data":
    {
        "diameter":1.75,
        "min":1.72,
        "max":1.84,
        "avg":1.75,
        "adc":840,
        "count":512
    }
}
```

| Parameter | Type | Description                      |
| --------- | ---- | -------------------------------- |
| diameter  | mm   | Last measured diameter           |
| min       | mm   | Smallest diameter measured       |
| max       | mm   | Maximum diameter measured        |
| avg       | mm   | Average diameter measured        |
| adc       | N    | Last raw ADC value (`0-4095`)    |
| count     | N    | Number diameter of samples taken |

### Reset diameter data

URL: `/api/v0/diameter/reset`

Reset collected diameter information (`min`, `max`, `avg`, `adc` and `count`).

### Read calibration data

URL: `/api/v0/calibration/read`

#### Response

Returns JSON data containing diameter information

```text
{
    "status":"ok",
    "data":
    [
        [53, 1.33],
        [1010, 2.15]
    ]
}
```

Data points are represented as `[ADC, mm]`.

### Create calibration point

URL: `/api/v0/calibration/create`

Create a calibration point using the provided `mm` and `adc` as parameters.

| Parameter | Type | Description              |
| --------- | ---- | ------------------------ |
| adc       | mm   | ADC value                |
| mm        | mm   | Equivalent `mm` diameter |

### Remove calibration point

URL: `/api/v0/calibration/remove`

Remove `mm` calibration point (if exists).

### Reset calibration points

URL: `/api/v0/calibration/reset`

Reset (remove) all calibration information and reset to initial values that are "hard-coded" in firmware as fail-safe.

### Reset WiFi

URL: `/api/v0/wifi/reset`

Reset (delete) WiFi information from the device.

### Reboot device

URL: `/api/v0/device/reboot`

Force device to reboot without power-cycling.
