Skip to main content
These endpoints provide backwards compatibility with the original greenhouse monitoring implementation. For multi-tenant deployments, use the /api/v1/tenants/{tenantId}/* endpoints instead.
These legacy endpoints are maintained for compatibility but new integrations should use the tenant-scoped endpoints.

Get Recent Messages

Retrieve the most recent sensor messages from Redis cache.
GET /api/v1/greenhouse/messages/recent

Query Parameters

limit
integer
default:"100"
Number of messages to retrieve (1-1000)

Response

Returns an array of RealDataDto objects with 22 sensor fields.
timestamp
string
ISO 8601 timestamp
TEMPERATURA INVERNADERO 01
number
Temperature reading for greenhouse 1
HUMEDAD INVERNADERO 01
number
Humidity reading for greenhouse 1
greenhouseId
string
Greenhouse identifier

Example

cURL
curl -X GET "https://api.example.com/api/v1/greenhouse/messages/recent?limit=50" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
Response
[
  {
    "timestamp": "2025-03-03T22:00:00Z",
    "TEMPERATURA INVERNADERO 01": 24.5,
    "HUMEDAD INVERNADERO 01": 65.3,
    "TEMPERATURA INVERNADERO 02": 23.8,
    "HUMEDAD INVERNADERO 02": 68.1,
    "TEMPERATURA INVERNADERO 03": 25.2,
    "HUMEDAD INVERNADERO 03": 62.9,
    "INVERNADERO_01_SECTOR_01": 1,
    "INVERNADERO_01_SECTOR_02": 0,
    "INVERNADERO_01_SECTOR_03": 1,
    "INVERNADERO_01_SECTOR_04": 1,
    "INVERNADERO_02_SECTOR_01": 0,
    "INVERNADERO_02_SECTOR_02": 1,
    "INVERNADERO_02_SECTOR_03": 0,
    "INVERNADERO_02_SECTOR_04": 1,
    "INVERNADERO_03_SECTOR_01": 1,
    "INVERNADERO_03_SECTOR_02": 1,
    "INVERNADERO_03_SECTOR_03": 0,
    "INVERNADERO_03_SECTOR_04": 0,
    "INVERNADERO_01_EXTRACTOR": 0,
    "INVERNADERO_02_EXTRACTOR": 1,
    "INVERNADERO_03_EXTRACTOR": 0,
    "RESERVA": 0,
    "greenhouseId": "001"
  }
]

Get Messages by Time Range

Query messages within a specific time period.
GET /api/v1/greenhouse/messages/range

Query Parameters

from
string
required
Start timestamp (ISO 8601 format)
to
string
required
End timestamp (ISO 8601 format)

Example

cURL
curl -X GET "https://api.example.com/api/v1/greenhouse/messages/range?from=2025-03-03T00:00:00Z&to=2025-03-03T23:59:59Z" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Get Sensor Statistics

Calculate statistics for a specific sensor over a time period.
GET /api/v1/greenhouse/statistics/{sensorId}
sensorId
string
required
Sensor field name (e.g., “TEMPERATURA INVERNADERO 01”)

Query Parameters

period
string
default:"24h"
Time period: 1h, 24h, 7d, 30d

Response

sensorId
string
Sensor field name
period
string
Time period analyzed
minValue
number
Minimum value in period
maxValue
number
Maximum value in period
avgValue
number
Average value in period
count
integer
Number of readings
lastValue
number
Most recent value

Example

cURL
curl -X GET "https://api.example.com/api/v1/greenhouse/statistics/TEMPERATURA%20INVERNADERO%2001?period=24h" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
Response
{
  "sensorId": "TEMPERATURA INVERNADERO 01",
  "period": "24h",
  "minValue": 18.5,
  "maxValue": 28.3,
  "avgValue": 23.7,
  "count": 1440,
  "lastValue": 24.1
}

Get Summary Statistics

Get aggregated statistics for all sensors.
GET /api/v1/greenhouse/statistics/summary

Query Parameters

period
string
default:"1h"
Time period: 1h, 24h, 7d, 30d
Returns statistics for all 22 sensor fields.

Example

cURL
curl -X GET "https://api.example.com/api/v1/greenhouse/statistics/summary?period=1h" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Get Cache Info

Check Redis cache status and metadata.
GET /api/v1/greenhouse/cache/info

Response

totalMessages
integer
Number of messages in cache (max 1000)
ttlSeconds
integer
Time-to-live in seconds (86400 = 24 hours)
maxCapacity
integer
Maximum cache capacity (1000)
utilizationPercentage
number
Cache utilization (0-100%)
cacheType
string
Data structure type (“Redis Sorted Set”)
oldestMessageTimestamp
string
Timestamp of oldest cached message
newestMessageTimestamp
string
Timestamp of newest cached message

Example

cURL
curl -X GET "https://api.example.com/api/v1/greenhouse/cache/info" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
Response
{
  "totalMessages": 1000,
  "ttlSeconds": 86400,
  "maxCapacity": 1000,
  "utilizationPercentage": 100.0,
  "cacheType": "Redis Sorted Set",
  "oldestMessageTimestamp": "2025-03-02T22:15:30Z",
  "newestMessageTimestamp": "2025-03-03T22:15:30Z"
}

Health Check

Simple health check endpoint.
GET /api/v1/greenhouse/health
Returns HTTP 200 with {"status": "UP"} if the service is healthy.

Example

cURL
curl -X GET "https://api.example.com/api/v1/greenhouse/health"

Migration Guide

For new implementations, use the tenant-scoped endpoints:
Legacy EndpointNew Endpoint
GET /api/v1/greenhouse/messages/recentGET /api/v1/sensors/latest
GET /api/v1/greenhouse/messages/rangeGET /api/v1/sensors/by-greenhouse/{greenhouseId}
GET /api/v1/greenhouse/statistics/{sensorId}GET /api/v1/statistics/historical-data
GET /api/v1/greenhouse/statistics/summaryGET /api/v1/statistics/summary
The new endpoints provide better multi-tenant isolation and support for filtering by tenant, greenhouse, and sensor.

Build docs developers (and LLMs) love