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.
Request a telemetry token for an edge device. Use farm credentials (email + password from portal).
💡 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).
Ingest NPK, moisture, microclimate, and light readings from a field sensor suite.
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.
Fetch interpolated NPK values and soil quality score across all fields in a farm.
Advisory & Decision Engine
Fetch AI-generated agronomic recommendations based on current farm state.
Get latest farm advisory, irrigation schedule, and risk alerts.
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.
| 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 |