POST Form - Send sensor data using form-urlencoded format
POST/api.php
Required Headers
Key
Value
Content-Type
application/x-www-form-urlencoded
Form Fields
Response
Form POST Example
# HTML form action
<form method="POST" action="http://localhost/iot-dashboard/api.php">
<input name="voltage" value="251.5" />
<input name="current" value="0.063" />
<input name="power" value="6.6" />
<input name="energy" value="0.006" />
<input name="frequency" value="50.0" />
<input name="power_factor" value="0.42" />
<button type="submit">Submit</button>
</form>
# JavaScript fetch with form dataconst data = new URLSearchParams();
data.append('voltage', 251.5);
data.append('current', 0.063);
data.append('power', 6.6);
data.append('energy', 0.006);
data.append('frequency', 50.0);
data.append('power_factor', 0.42);
fetch('/api.php', { method: 'POST', body: data })
.then(r => r.json())
.then(d => console.log(d));
GET - Query power monitoring data from the database
GET/api.php
Available Endpoints
Endpoint
Description
/api.php?action=summary
Min/Max/Avg statistics for all fields
/api.php?action=timeseries
Time series data for charts
/api.php?action=daily
Daily aggregated readings
/api.php?action=table&page=1
Paginated table data
Try It
Response
GET Query Examples
# Summary statistics (Min/Max/Avg)
GET /api.php?action=summary
# Time series data
GET /api.php?action=timeseries
# Daily aggregated data
GET /api.php?action=daily
# Paginated table
GET /api.php?action=table&page=1
curl Examples - Test the API from command line
POST JSON via curl
# POST JSON data to /api.php
curl -X POST http://localhost/iot-dashboard/api.php ^
-H "Content-Type: application/json" ^
-d '{"voltage":251.5,"current":0.063,"power":6.6,"energy":0.006,"frequency":50.0,"power_factor":0.42}'
POST Form via curl
# POST form-urlencoded data
curl -X POST http://localhost/iot-dashboard/api.php ^
-H "Content-Type: application/x-www-form-urlencoded" ^
-d "voltage=251.5¤t=0.063&power=6.6&energy=0.006&frequency=50.0&power_factor=0.42"
GET Summary
# GET summary statistics (Min/Max/Avg)
curl "http://localhost/iot-dashboard/api.php?action=summary"
GET Time Series
# GET time series data
curl "http://localhost/iot-dashboard/api.php?action=timeseries"
GET Daily
# GET daily aggregated data
curl "http://localhost/iot-dashboard/api.php?action=daily"
GET Table (Paginated)
# GET paginated table data
curl "http://localhost/iot-dashboard/api.php?action=table&page=1"