Get Battery & Charging Timeline
GET/api/v1/analytics/battery-charging
Battery status (percentage) over a time window. The server reads raw battery events from event_analytics, carries the last known value forward to seed the window start, tags each reading as charging (rising %) or discharging (falling %), and returns an ascending time series. When export=true the response is a CSV file download instead of JSON.
Request
Query Parameters
Mandatory. Inclusive window start — ISO 8601 datetime or epoch milliseconds.
Mandatory. Inclusive window end — ISO 8601 datetime or epoch milliseconds.
Possible values: [true, false]
When true, returns a CSV file download (columns: timestamp, battery_percentage, status). When false or omitted, returns the standard JSON response.
Responses
- 200
- 400
- 500
JSON battery timeline (default) or CSV file download (when export=true)
- application/json
- text/csv
- Schema
- Example (from schema)
Schema
- Array [
- ]
data objectrequired
window objectrequired
series object[]required
Possible values: [charging, discharging]
{
"success": true,
"message": "string",
"data": {
"window": {
"start": "string",
"end": "string",
"elapsed_ms": 0,
"sample_count": 0
},
"charging_events": 0,
"series": [
{
"t": "string",
"val": 0,
"status": "charging"
}
]
},
"status": 0
}
- Schema
Schema
string
Invalid time range
- application/json
- Schema
- Example (from schema)
Schema
{
"success": true,
"message": "string",
"status": 0
}
Internal server error
- application/json
- Schema
- Example (from schema)
Schema
{
"success": true,
"message": "string",
"status": 0
}