Sensor Readouts — API Documentation

Base URL

http://localhost:5000/api

GET /api/sensors

GET/api/sensors

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" }
]
POST/api/sensors

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:

CodeCondition
400name is missing or empty
409Sensor with this name already exists

GET /api/sensors/:id/types

GET/api/sensors/:id/types

Return distinct readout types available for a given sensor.

curl

curl http://localhost:5000/api/sensors/1/types

Response 200

["humidity", "pressure", "temperature"]

Errors:

CodeCondition
404Sensor not found

GET /api/sensors/:id/readouts

GET/api/sensors/:id/readouts

Return the latest readouts for a sensor. Optional type query parameter filters by readout type.

Query parameters:

ParamTypeDescription
typestringFilter 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" }
]
POST/api/sensors/:id/readouts

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:

CodeCondition
400Missing type or value, or value is not a number
404Sensor not found
Note: All request and response bodies use application/json.