API Reference
Base URL
1 |
|
For this project
1 |
|
Endpoints
Data Tables Overview (CRUD)
Table | Endpoint | Description |
---|---|---|
Device | /device |
Stores registered devices |
Reading | /reading |
Stores sensor readings from devices |
Sensor | /sensor |
Defines available sensors |
SensorData | /sensordata |
Links readings with sensor values |
Setting | /setting |
Configuration settings |
Views | /views |
Views |
Custom Endpoints
Endpoint | Description |
---|---|
/reading-with-sensordata |
atomic POST request |
/installation/publish |
Publisher |
/installation/ws |
WebSocket connection |
/installation |
reverse proxy |
Device
GET /device
- Get all devicesGET /device/{id}
- Get a device by IDPOST /device
- Create a devicePUT /device/{id}
- Update a deviceDELETE /device/{id}
- Delete a device
GET /device
Example Response:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
GET /device/{id}
Example Response:
1 2 3 4 5 |
|
POST /device
Example Request Body (Single Insert):
1 2 3 4 |
|
Example Request Body (Multiple Inserts):
1 2 3 4 |
|
Example Response:
1 2 3 |
|
PUT /device/{id}
Example Request Body:
1 2 3 |
|
Example Response:
1 2 3 |
|
DELETE /device/{id}
Example Response:
1 2 3 |
|
Device
GET /reading
- Get all readingsGET /reading/{id}
- Get a reading by IDPOST /reading
- Create a readingPUT /reading/{id}
- Update a readingDELETE /reading/{id}
- Delete a reading
GET /reading
Example Response:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
GET /reading/{id}
Example Response:
1 2 3 4 5 |
|
POST /reading
Example Request Body (Single Insert):
1 2 3 |
|
Example Request Body (Multiple Inserts):
1 |
|
Example Response:
1 2 3 |
|
PUT /reading/{id}
Example Request Body:
1 2 3 |
|
Example Response:
1 2 3 |
|
DELETE /reading/{id}
Example Response:
1 2 3 |
|
Sensor
GET /sensor
- Get all sensorsGET /sensor/{id}
- Get a sensor by IDPOST /sensor
- Create a sensorPUT /sensor/{id}
- Update a sensorDELETE /sensor/{id}
- Delete a sensor
GET /sensor
Example Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
GET /sensor/{id}
Example Response:
1 2 3 4 5 6 |
|
POST /sensor
Example Request Body (Single Insert):
1 2 3 4 5 |
|
Example Request Body (Multiple Inserts):
1 2 3 4 |
|
Example Response:
1 2 3 |
|
PUT /sensor/{id}
Example Request Body:
1 2 3 |
|
Example Response:
1 2 3 |
|
DELETE /sensor/{id}
Example Response:
1 2 3 |
|
SensorData
GET /sensordata
- Get all sensor dataGET /sensordata/{id}
- Get a sensor data by IDPOST /sensordata
- Create a sensor dataPUT /sensordata/{id}
- Update a sensor dataDELETE /sensordata/{id}
- Delete a sensor data
GET /sensordata
Example Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
GET /sensordata/{id}
Example Response:
1 2 3 4 5 6 |
|
POST /sensordata
Example Request Body (Single Insert):
1 2 3 4 5 |
|
Example Request Body (Multiple Inserts):
1 2 3 4 |
|
Example Response:
1 2 3 |
|
PUT /sensordata/{id}
Example Request Body:
1 2 3 |
|
Example Response:
1 2 3 |
|
DELETE /sensordata/{id}
Example Response:
1 2 3 |
|
Setting
GET /setting
- Get all settingsGET /setting/{id}
- Get a setting by IDPOST /setting
- Create a settingPUT /setting/{id}
- Update a settingDELETE /setting/{id}
- Delete a setting
GET /setting
Example Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
GET /setting/{id}
Example Response:
1 2 3 4 5 6 7 |
|
POST /setting
Example Request Body (Single Insert):
1 2 3 4 5 6 |
|
Example Request Body (Multiple Inserts):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Example Response:
1 2 3 |
|
PUT /setting/{id}
Example Request Body:
1 2 3 |
|
Example Response:
1 2 3 |
|
DELETE /setting/{id}
Example Response:
1 2 3 |
|
Views
get /views/LatestDeviceReadings?device_id={id}
This view retrieves only the most recent sensor readings for each device.
Example Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
Custom API Requests
POST /reading-with-sensordata
Creates a reading and its associated sensor data in a single atomic POST request.
Example Request Body:
1 2 3 4 5 6 7 8 9 10 11 |
|
Example Response:
1 2 3 |
|
POST /reading-with-sensordata
Installation WebSocket & Publishing Endpoints
These endpoints are used for real-time communication between the backend and frontend via WebSocket-over-TLS, powered by ngx_http_push_stream_module
.
WebSocket Subscriber
GET /installation/ws
Establishes a WebSocket connection and subscribes the client to the installation
channel.
- Protocol: WebSocket (
wss://
in production) - Expected Use Case: Frontend client connects here to receive real-time updates (e.g., active carousel index).
- Connection Type: Long-lived, bidirectional.
Publisher Endpoint
POST /installation/publish
Publishes a new message to all subscribers of the installation
channel.
- Body Format (Raw text):
1 |
|
- Content-Type:
text/plain
- Authentication: Restricted (handled by server access control or internal-only publishing)
- Expected Use Case: The backend (or ESP32) sends state updates like
currentIndex
to the frontend via this channel.
Installation Reverse Proxy Endpoint
GET /installation/...
All remaining requests starting with /installation/
are reverse proxied to the embedded HTTPS server of the ESP32:
1 |
|
- Use Case: Internal API call delegation to ESP32-secured HTTPS endpoints.
- Security: Certificate verification is skipped (
proxy_ssl_verify off
),