The Surqo KPI engine translates raw sensor readings into decision-ready agronomic indices. Rather than exposing raw numbers, it computes well-established scientific formulas — Magnus equation for VPD, Penman-Monteith-derived ETc, degree-day accumulation for GDD, and a probabilistic pest-risk model — so farmers can act on insight rather than data. All KPI endpoints require authentication via a Supabase JWT and verify that the requesting user owns the target farm.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ricardomb-tech/surqo/llms.txt
Use this file to discover all available pages before exploring further.
KPI Definitions
| KPI | Formula | Interpretation |
|---|---|---|
| VPD (kPa) | es − ea (Magnus) | < 0.8 optimal · 0.8–1.6 acceptable · > 1.6 stress · > 2.5 critical |
| ETc (mm/day) | ET₀ × Kc | Daily water consumption by crop |
| GDD (degree-days) | (Tmax+Tmin)/2 − Tbase | Accumulated heat for crop development |
| Water deficit (mm) | ETc_7d − rain_7d | Water shortfall for the week |
| Soil health score (0–100) | Composite moisture + temp | > 70 healthy · < 50 critical |
| Pest risk (%) | Temp + humidity + crop model | > 70 = alert |
Crop Kc Coefficients
ETc is calculated asET₀ × Kc. The following crop coefficients are used by KPIService.calculate_etc():
| Crop | Kc coefficient |
|---|---|
| Arroz | 1.20 |
| Maíz | 1.15 |
| Plátano | 1.10 |
| Algodón | 1.05 |
| Café | 0.95 |
| Yuca | 0.85 |
1.0.
Endpoints
GET /api/v1/kpis/farm/{farm_id}
Returns a full KPI summary computed from the last 24 hours of sensor readings for the farm.UUID of the farm. The authenticated user must be the owner; returns
403 otherwise.{"error": "Sin lecturas en las últimas 24 horas"} when no readings exist for the period.
Response — 200 OK
GET /api/v1/kpis/farm/{farm_id}/vpd-history
Returns a time series of VPD values for the last 48 hours, ordered chronologically. Only readings that contain a non-nullvpd_kpa value are included.
UUID of the farm.
200 OK — list[{timestamp, vpd_kpa}]
GET /api/v1/kpis/farm/{farm_id}/water-balance
Returns the estimated 7-day water balance for the farm. ETc is calculated using an ET₀ approximation of4.5 mm/day (standard for the Colombian tropical zone) and the Kc coefficient for the farm’s crop type. Rainfall is not yet sourced from sensors and defaults to 0.0 mm — for a weather-adjusted balance, use the full AI analysis endpoint (POST /api/v1/analysis/analyze).
UUID of the farm.
200 OK
GET /api/v1/kpis/farm/{farm_id}/pest-risk
Returns the current pest risk level based on the last 24 hours of readings. Risk is modelled from average air temperature and humidity against known conditions for fungal and crop-specific pathogens.UUID of the farm.
200 OK
{"error": "Sin lecturas recientes para calcular riesgo"} when no readings exist in the last 24 hours.
VPD Formula Detail
Magnus equation — source: kpi_service.py
Magnus equation — source: kpi_service.py
The VPD is calculated by
KPIService.calculate_vpd() using the Magnus approximation:T is the average air temperature in °C and RH is the relative humidity percentage. The result is floored at 0.0 and rounded to 3 decimal places.Soil health score — source: kpi_service.py
Soil health score — source: kpi_service.py
The soil health score is a composite of three factors:
Pest risk model — source: kpi_service.py
Pest risk model — source: kpi_service.py
Risk is based on temperature–humidity thresholds with crop-specific pathogen mapping: