REST API Specification¶
The REST API is exposed by the FastAPI Gateway service at http://localhost:8000 (or https://api.yourdomain.com).
Authentication¶
All protected endpoints require an HTTP Authorization header containing a valid Bearer token:
Auth Endpoints¶
Register User¶
Request Body: Response (201 Created):Login (Obtain Tokens)¶
Request Body: Response (200 OK):{
"access_token": "eyJhbGciOi...",
"refresh_token": "Au1R5Xk...",
"token_type": "bearer",
"expires_in_minutes": 15
}
Refresh Access Token¶
Request Body: Response (200 OK): Returns freshaccess_token.
Channels Endpoints¶
List User Channels¶
Response (200 OK): Array of Channel objects.Create Channel¶
Request Body:{
"name": "Greenhouse Alpha",
"description": "Climate and moisture monitoring",
"is_public": false
}
Get Channel Details¶
List Channel Fields¶
Response (200 OK):[
{"id": 1, "name": "temperature", "data_type": "numeric", "created_at": "..."},
{"id": 2, "name": "humidity", "data_type": "numeric", "created_at": "..."}
]
Hardware Devices Endpoints¶
List Devices¶
Provision Device¶
Request Body: Response (201 Created):{
"id": 1,
"channel_id": 1,
"name": "ESP32_Outdoor_Unit",
"mqtt_username": "d_0a1b2c3d4e",
"mqtt_password": "raw_generated_password_revealed_once",
"created_at": "2026-11-12T00:00:00Z"
}
API Keys Endpoints¶
List API Keys¶
Generate API Key¶
Request Body: Response (201 Created):{
"id": 1,
"channel_id": 1,
"scope": "write",
"api_key": "tl_write_xxxxxxxxxxxxxxxxxxxx", // Revealed once
"created_at": "2026-11-12T00:00:00Z"
}
MQTT Sessions Endpoint¶
Request Frontend MQTT Session¶
Response (200 OK):{
"username": "s_f7e8d9c0b1",
"password": "temporary_session_password",
"expires_at": "2026-11-13T00:00:00Z"
}
Telemetry Data Endpoints¶
Query Telemetry Series¶
GET /channels/{channel_id}/data?resolution=auto&fields=temperature,humidity&start=2026-11-11T00:00:00Z
resolution: auto, raw, 1m, or 1h.
- fields: Comma-separated list of field names (optional).
- start: ISO-8601 start timestamp.
- end: ISO-8601 end timestamp.