REST API · v1.0

VerdeX Farm API

Real-time data from a DWC hydroponics smart farm in Chiang Mai. Sensors, growing-phase status, batch traceability, and business analytics — all available as a clean RESTful API.

60 req / min JSON responses HTTPS only Public + authenticated
Explore Endpoints Get an API Key

Quickstart

2 min · curl

Try it without authentication

The public endpoints require no signup. Just hit them with curl, fetch, or your browser:

# Latest sensor readings
curl https://verdex-web.verdexfarm.workers.dev/api/v1/sensors

# Farm status with health score
curl https://verdex-web.verdexfarm.workers.dev/api/v1/farm/status

# Last 24 hours of historical sensor data
curl "https://verdex-web.verdexfarm.workers.dev/api/v1/sensors/history?hours=24"

With an API key (business endpoints)

Authenticated routes require an X-API-Key header. Request a key via LINE OA:

curl -H "X-API-Key: your_key_here" \
  https://verdex-web.verdexfarm.workers.dev/api/v1/orders

Public Endpoints

No auth required
GET /api/v1/sensors Latest water temperature, air temperature, and humidity readings.

Description

Returns the most recent sensor sample (within the last 30 minutes) along with status (OK / WARNING / NO_DATA) and threshold reference values.

Try it →
GET /api/v1/sensors/history Historical sensor data with configurable time range and aggregation.

Query Parameters

hours (integer, default 6, max 168) — Hours of history to retrieve.

Try it →
GET /api/v1/farm/status Growing phase, days since planting, and a 0-100 health score.

Description

Combines the planting calendar with live sensor readings to compute a health score. The score starts at 100 and is penalized based on how far each reading deviates from its optimal range.

Try it →
GET /api/v1/batch/:id Batch traceability — log entry plus sensor averages over the grow period.

Path Parameters

id (string) — Batch identifier from farm_logs.

Try it →

Authenticated Endpoints

X-API-Key required
GET /api/v1/orders List orders from the CRM, optionally filtered by status. Auth

Query Parameters

status (string, optional) — pending, confirmed, delivered, cancelled.
limit (integer, default 50, max 200).

GET /api/v1/restaurants List active restaurants in the customer CRM. Auth

Description

Returns all restaurants currently in the CRM with name, channel, delivery day, and status. Contact details and pricing are intentionally excluded from the public API surface.

GET /api/v1/analytics/summary Business metrics — revenue, orders, top customers. Auth

Query Parameters

days (integer, default 30, max 365) — History window.

Response Format & Errors

Consistent JSON envelope

Success envelope

{
  "ok": true,
  "data": { /* endpoint payload */ },
  "meta": {
    "timestamp": "2026-04-09T10:23:11.412Z",
    "version": "1.0"
  }
}

Error envelope

{
  "ok": false,
  "error": {
    "code": "RATE_LIMITED",
    "message": "Rate limit exceeded. Maximum 60 requests per minute."
  }
}

Error codes: INFLUX_ERROR, DATABASE_ERROR, NO_DATABASE, NOT_FOUND, UNAUTHORIZED, RATE_LIMITED, METHOD_NOT_ALLOWED, INTERNAL_ERROR.