REST API
This article covers the device REST API for local network access. For remote access via the cloud, see the Cloud API. Client libraries are available for Python and Go.
Authentication
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.
To authenticate with a token instead of a password, pass it as a Bearer token in the Authorization header:
Endpoints
Examples below use 192.168.0.100 as the device IP. Find your device's IP address in the access overview.
GET/api/v1/metricsMetrics snapshot
Returns all current metric values. Filter by topic glob or retrieve a single value as plain text.
Query parameters
| topic | string | Topic glob filter, e.g. battery* or total/*. |
| value | integer | Set to 1 to return the value as plain text instead of JSON. |
Request
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": "%"}
]
POST/api/v1/metricsWrite a setting
Sends a new value to the inverter. On failure a 422 is returned with an error message. Use the topic field from a GET response to know what topics are writable.
Body parameters
| topic | stringrequired | The metric topic to write, e.g. inverter_1/output_source_priority. |
| value | stringrequired | The new value to set. |
Request
-H "Content-Type: application/json" \
-d '{"topic": "inverter_1/output_source_priority", "value": "Utility first"}'
Response
WS/api/socket/websocketStream metrics via WebSocket
Streams live metrics as they update using the SolarAssistant WebSocket API. Pass your password or token as a query parameter when connecting.
Query parameters
| password | string | Device password. |
| token | string | Bearer token, as an alternative to password. |
Request
After connecting, join the metrics channel. See the WebSocket API docs for channel events and topic format.
Topic structure
Topics follow the same structure as MQTT. Metrics are grouped under total/, inverter_1/, inverter_2/, battery_1/, etc. Some common topics:
| Topic | Description |
| 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.