The Readings API is the primary ingestion path for sensor measurements. Edge devices (ESP32 nodes, LoRa gateways, serial bridges) POST readings as they arrive; the dashboard and analytics services consume them via the GET endpoint. Every POST also triggers theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/diarpicu2022-commits/backend-AgroPulse/llms.txt
Use this file to discover all available pages before exploring further.
GreenhouseMonitor observer pipeline, which runs anomaly detection against any active thresholds configured for the sensor.
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/readings | List recent readings with optional filters |
POST | /api/readings | Ingest a new reading and trigger anomaly detection |
GET /api/readings
Returns the most recent readings, sorted by timestamp descending. Results are always paginated — the default page size is 100 rows.Query parameters
Maximum number of readings to return. Results are ordered newest-first.
Filter readings to a specific sensor ID. Cannot be combined with
greenhouseId — sensor takes precedence.Filter readings to all sensors that belong to this greenhouse. Ignored when
sensor is also present.Response
curl examples
POST /api/readings
Saves a sensor reading and immediately passes it toGreenhouseMonitor.processSensorReading(). The monitor checks active thresholds for the sensor and emits anomaly events when values fall outside configured bounds.
Auto-registration: when
sensorId is 0 or omitted, and greenhouseId plus sensorType are both present, the API looks up an existing sensor by (greenhouseId, source, sensorType). If no match is found, a new sensor is created automatically with the name <TYPE> (auto) and active = true. The new sensor ID is then assigned to the reading before it is persisted. This allows ESP32 devices to submit readings without pre-registering their sensors.Body parameters
ID of the sensor that produced this reading. Set to
0 or omit to trigger auto-registration when greenhouseId and sensorType are present.The measured value. Units are determined by
sensorType (°C, %, lux, ppm, pH, m/s).ID of the greenhouse the reading originates from. Required for auto-registration.
Transport or origin of the reading. Common values:
MANUAL, ESP32_WIFI, ESP32_LORA, ESP32_SERIAL.Measurement type. Must be a valid
SensorType enum value. Used during auto-registration and stored on the reading record. See the Sensors API for the full list of values.Response fields
Auto-generated reading identifier.
ID of the sensor that produced this reading. Populated automatically when auto-registration runs.
SensorType enum value describing the measurement category.The raw measurement value.
ID of the originating greenhouse.
Transport identifier (
MANUAL, ESP32_WIFI, ESP32_LORA, ESP32_SERIAL).ISO-8601 datetime set at ingestion time, e.g.
"2024-06-01T14:32:00".