REST API
Authentication
Local access
Connect directly to your SolarAssistant device on your local network using your device password. A password must be configured on the device before the API can be used - see the local password guide for instructions.
Cloud access
When accessing a SolarAssistant unit via the cloud, requests go through two layers of security. See the sacli authorize section for details.
Endpoints
The examples below assume your device's IP address is 192.168.0.100. You can find your device's IP address in the access overview.
Get all metrics:
Filter by topic glob:
curl -u admin:<password> "http://192.168.0.100/api/v1/metrics?topic=total/*"
Get a single value as plain text:
Example JSON response:
{"topic": "total/pv_power", "group": "Status", "name": "PV power", "value": 1240, "unit": "W"},
{"topic": "total/load_power", "group": "Status", "name": "Load power", "value": 940, "unit": "W"},
{"topic": "total/battery_state_of_charge", "group": "Status", "name": "Battery state of charge", "value": 80, "unit": "%"}
]
To authenticate with a token instead of a password, pass it as a Bearer token in the Authorization header:
Adjusting solar settings
POST to /api/v1/metrics with a JSON body containing the topic and new value:
-H "Content-Type: application/json" \
-d '{"topic": "inverter_1/output_source_priority", "value": "Utility first"}'
Example success response:
On failure a 422 is returned with an error message. The topic format is the same as the read endpoints — use the topic field from a GET response to know what to write back.
Topic structure
Topics follow the same structure as MQTT. Metrics are grouped under total/, inverter_1/, inverter_2/, battery_1/, etc. Some common topics:
- total/pv_power - combined PV power across all inverters (W)
- total/load_power - total load power (W)
- total/grid_power - grid power, negative = export (W)
- total/battery_power - battery power, negative = charging (W)
- total/battery_state_of_charge - battery state of charge (%)
- inverter_1/device_mode - current inverter mode
- battery_1/voltage - battery voltage (V)
To see all available topics for your specific inverter and battery model, call the metrics endpoint without a filter and inspect the topic fields in the response.