> GET Device Data Example
Request
http
GET /api/device/12345/data
Authorization: Bearer YOUR_ACCESS_TOKEN
Response (JSON)
json
{
\"device_id\": \"12345\",
\"temperature\": \"22.5\",
\"battery\": \"85%\",
\"last_update\": \"2025-03-31T12:00:00Z\"
}
> POST Command to Device
Request
http
POST /api/device/12345/command
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN{\”command\”: \”update_interval\”,
\”value\”: \”10_minutes\”
}
Response
json
{
\"status\": \"success\",
\"message\": \"Update interval set to 10 minutes\"
}
Managing API Responses
The API follows a structured JSON format for responses:
| Status | Description |
|---|---|
200 OK |
Successful request |
400 Bad Request |
Invalid input or missing parameters |
401 Unauthorized |
Missing or invalid authentication |
500 Internal Server Error |
Unexpected server issue |
Example error response:
json
{
\"error\": \"Invalid API key\",
\"code\": 401
}