API Reference
Authentication
All API requests require an API key to be included in the Authorization
header:
Authorization: Bearer YOUR_API_KEY
Endpoints
GET /api/sensors
Retrieves a list of all sensors associated with your account.
{ "sensors": [ { "id": "sensor-1", "name": "Living Room Sensor", "location": "Living Room", "last_reading": { "temperature": 22.5, "humidity": 45.2, "timestamp": "2023-10-27T10:00:00Z" } }, { "id": "sensor-2", "name": "Bedroom Sensor", "location": "Bedroom", "last_reading": { "temperature": 20.1, "humidity": 50.8, "timestamp": "2023-10-27T10:00:00Z" } } ] }
GET /api/sensors/[id]
Retrieves data for a specific sensor.
{ "id": "sensor-1", "name": "Living Room Sensor", "location": "Living Room", "readings": [ { "temperature": 22.5, "humidity": 45.2, "timestamp": "2023-10-27T10:00:00Z" }, { "temperature": 22.7, "humidity": 44.8, "timestamp": "2023-10-27T09:55:00Z" }, { "temperature": 22.3, "humidity": 45.5, "timestamp": "2023-10-27T09:50:00Z" } ] }
Error Codes
The API uses standard HTTP status codes to indicate success or failure of a request. Common error codes include:
- 400 Bad Request: The request was malformed or invalid.
- 401 Unauthorized: The API key was missing or invalid.
- 404 Not Found: The requested resource was not found.
- 500 Internal Server Error: An unexpected error occurred on the server.