← Back to API Reference

API: Sensor History

Access historical sensor data from your Annaboto — temperature, humidity, and water levels over time. Use raw readings for detailed recent data, or the summary endpoint for efficient full-grow charting.

GET /sensor_history

Returns raw sensor readings from the device's SQLite database. Best for recent, high-resolution data (last 24 hours).

Endpoint: GET http://<device-ip>:8080/annaboto/api/sensor_history

Query Parameters

Parameter Type Default Description
limit integer 500 Number of readings to return (most recent first). Keep under 2000 to avoid timeouts.
grow_id string current grow Filter by grow. Use a specific ID, "current" for active grow, or "all" for unfiltered.
start ISO 8601 — Start of time window (e.g., 2026-05-01T00:00:00Z)
end ISO 8601 — End of time window

Example Request

# Last 288 readings (~24 hours at 5-min intervals)
curl "http://192.168.0.103:8080/annaboto/api/sensor_history?limit=288"

# Readings for the active grow only
curl "http://192.168.0.103:8080/annaboto/api/sensor_history?grow_id=current&limit=500"

Response Format

Array of reading objects, most recent first:

[
  {
    "time": "2026-05-16T14:30:00Z",
    "temperature": 23.1,
    "humidity": 48.5,
    "fresh_water": 1.0,
    "grow_water": 0.85,
    "waste_water": 0.02
  },
  ...
]
Performance note: Response times can vary (1–10 seconds) depending on device CPU load. For charting full-grow data, use the /sensor_history/summary endpoint instead.

GET /sensor_history/summary

Returns pre-computed hourly averages for the entire grow period. Designed for fast chart rendering — responds in under 500ms regardless of grow length.

Endpoint: GET http://<device-ip>:8080/annaboto/api/sensor_history/summary

Query Parameters

Parameter Type Default Description
grow_id string current grow Filter by grow. Accepts specific ID or "current".
start ISO 8601 — Optional start of time window
end ISO 8601 — Optional end of time window

Example Request

curl "http://192.168.0.103:8080/annaboto/api/sensor_history/summary"

Response Format

{
  "total_hours": 1800,
  "grow_start": "2026-03-01T00:00:00Z",
  "hourly": [
    {
      "hour": "2026-03-01T00:00:00Z",
      "avg_temperature": 22.5,
      "min_temperature": 21.8,
      "max_temperature": 23.1,
      "avg_humidity": 45.2,
      "min_humidity": 43.0,
      "max_humidity": 47.5,
      "avg_fresh_water": 1.0,
      "avg_grow_water": 0.9,
      "avg_waste_water": 0.0,
      "sample_count": 12
    },
    ...
  ]
}

How It Works

No Active Grow

If no grow is active and no grow_id is specified, the response returns:

{
  "total_hours": 0,
  "grow_start": null,
  "hourly": []
}

Recommended Usage Pattern

For a complete chart experience, make two parallel requests:

  1. GET /sensor_history/summary — full grow at hourly resolution (fast, pre-computed)
  2. GET /sensor_history?limit=288 — last 24 hours at full resolution (5-minute intervals)