Demo module · Illustrative sample data  |  ← Home · Photosynthesis Index · Architecture · Portal · All pages
QAgroTrust
QAgroTrust™API Documentation

API Schema & Developer Docs

Technical specifications for IoT edge nodes, mobile apps, and third-party integrations. All endpoints are HTTPS-only, JSON request/response.

Authentication

All requests require a Bearer token issued by the QAgroTrust platform per farm.

POST /api/auth/farm-token

Request a telemetry token for an edge device. Use farm credentials (email + password from portal).

Request POST /api/auth/farm-token Content-Type: application/json { "email": "farmer@hillsidecoops.in", "password": "secure_password_here", "device_id": "EDGE_FARM_0847_FIELD_A" }
Response 200 { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "expires_in": 2592000, "farm_id": "FARM-0847", "scope": "telemetry:write" }

💡 Token Management

Tokens expire after 30 days. Refresh by calling /api/auth/farm-token again. For long-running edge devices, schedule a refresh every 25 days. Include the token in all subsequent requests as: Authorization: Bearer <token>

Telemetry Ingestion

Edge nodes send sensor readings to this endpoint every 15 minutes (configurable).

POST /api/telemetry/ingest

Ingest NPK, moisture, microclimate, and light readings from a field sensor suite.

Request POST /api/telemetry/ingest Authorization: Bearer eyJhbGciOiJIUzI1NiIs... Content-Type: application/json { "farmId": "FARM-0847", "fieldName": "Field A North Block", "lat": 12.4537, "lng": 78.9423, "timestamp": "2026-07-20T14:32:00Z", "n_kg_ha": 124.5, "p_kg_ha": 38.2, "k_kg_ha": 151.8, "soil_moisture_pct": 58.3, "temp_c": 28.5, "rh_pct": 67.2, "par_umol_m2_s": 1240, "chlorophyll_spad": 42.8, "edge_confidence": 0.94 }
Response 202 Accepted { "status": "queued", "reading_id": "TEL-20260720-143200-FARM0847-FA", "edge_efficiency_pct": 87, "alerts": [] }

Edge Efficiency: The backend computes photosynthetic efficiency locally using the same N/P/K model as the digital-twin page. If efficiency < 65%, an alert is returned and pushed to the farmer app in real-time.

NPK Netting & Soil Map

Retrieve spatially-mapped NPK values for a farm or field, updated from latest telemetry.

GET /api/farms/{farmId}/npk-map

Fetch interpolated NPK values and soil quality score across all fields in a farm.

Request GET /api/farms/FARM-0847/npk-map?zoom=5 Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
Response 200 { "farmId": "FARM-0847", "fields": [ { "fieldName": "Field A North Block", "n_kg_ha": 124.5, "p_kg_ha": 38.2, "k_kg_ha": 151.8, "soil_health_score": 87, "last_updated": "2026-07-20T14:32:00Z", "recommendations": [ { "type": "nutrient", "severity": "info", "text": "NPK balance optimal. Maintain current input schedule." } ] } ] }

Advisory & Decision Engine

Fetch AI-generated agronomic recommendations based on current farm state.

GET /api/farms/{farmId}/advisory

Get latest farm advisory, irrigation schedule, and risk alerts.

Request GET /api/farms/FARM-0847/advisory?fields=Field%20A%20North%20Block Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
Response 200 { "farmId": "FARM-0847", "generated_at": "2026-07-20T14:35:00Z", "advisory": { "irrigation": { "action": "water_today", "timing": "06:00 UTC", "duration_hours": 2.5, "rationale": "Soil moisture forecasted to drop below 40% by tomorrow 14:00" }, "nutrition": { "action": "field_b_potassium_alert", "crop": "Ragi (Finger Millet)", "severity": "warning", "text": "Field B K trending below optimum. Consider split dose in 3–5 days." }, "disease_risk": { "risk_level": 0.12, "status": "low", "next_check": "2026-07-21T14:00:00Z" } } }

Rate Limits & Quotas

Endpoint Limit Window
POST /api/telemetry/ingest 1000 readings/day per farm 24 hours
GET /api/farms/{farmId}/npk-map 100 requests/day 24 hours
GET /api/farms/{farmId}/advisory 288 requests/day (1 every 5 min) 24 hours
POST /api/auth/farm-token 10 tokens/day per farm 24 hours

Limits are soft; brief spikes (10%) are tolerated. Sustained overage (>20%) will result in HTTP 429 (Too Many Requests). Contact support to increase quotas for high-volume operations.

Error Handling

All errors return JSON with error and message fields.

Example Error Response { "error": "invalid_token", "message": "Token expired or invalid", "status": 401 }
Code Reason Action
400 Bad request (invalid schema) Validate payload against examples above
401 Unauthorized (bad/expired token) Request fresh token from /api/auth/farm-token
403 Forbidden (insufficient permissions) Check token scope; request admin escalation if needed
429 Rate limit exceeded Back off and retry after 60 seconds; contact support for quota increase
500 Server error Retry after 30 seconds; report to support if persistent