http://localhost:5000/api
Return a list of all sensors ordered by name.
curl
curl http://localhost:5000/api/sensors
Response 200
[
{ "id": 1, "name": "outdoor-station" },
{ "id": 2, "name": "indoor-unit" }
]
Create a new sensor.
curl
curl -X POST http://localhost:5000/api/sensors \
-H "Content-Type: application/json" \
-d '{"name": "new-sensor"}'
Response 201
{ "id": 5, "name": "new-sensor" }
Errors:
| Code | Condition |
|---|---|
| 400 | name is missing or empty |
| 409 | Sensor with this name already exists |
Return distinct readout types available for a given sensor.
curl
curl http://localhost:5000/api/sensors/1/types
Response 200
["humidity", "pressure", "temperature"]
Errors:
| Code | Condition |
|---|---|
| 404 | Sensor not found |
Return the latest readouts for a sensor. Optional type query parameter filters by readout type.
Query parameters:
| Param | Type | Description |
|---|---|---|
| type | string | Filter by type (e.g. temperature) |
curl
# all types
curl http://localhost:5000/api/sensors/1/readouts
# filter by type
curl "http://localhost:5000/api/sensors/1/readouts?type=temperature"
Response 200
[
{ "value": 24.31, "timestamp": "2026-09-11T10:30:00" },
{ "value": 24.15, "timestamp": "2026-09-11T10:29:30" }
]
Add a new readout to an existing sensor. Timestamp is generated server-side.
curl
curl -X POST http://localhost:5000/api/sensors/1/readouts \
-H "Content-Type: application/json" \
-d '{"type": "temperature", "value": 22.5}'
Response 201
{
"id": 2702,
"sensor_id": 1,
"type": "temperature",
"value": 22.5,
"timestamp": "2026-09-11T17:00:00.123456"
}
Errors:
| Code | Condition |
|---|---|
| 400 | Missing type or value, or value is not a number |
| 404 | Sensor not found |
application/json.