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.

curl -u admin:<password> http://192.168.0.100/api/v1/metrics

To authenticate with a token instead of a password, pass it as a Bearer token in the Authorization header:

curl -H "Authorization: Bearer <token>" http://192.168.0.100/api/v1/metrics

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
topicstringTopic glob filter, e.g. battery* or total/*.
valueintegerSet to 1 to return the value as plain text instead of JSON.
Request
curl -u admin:<password> http://192.168.0.100/api/v1/metrics
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
topicstringrequiredThe metric topic to write, e.g. inverter_1/output_source_priority.
valuestringrequiredThe new value to set.
Request
curl -u admin:<password> -X POST http://192.168.0.100/api/v1/metrics \
  -H "Content-Type: application/json" \
  -d '{"topic": "inverter_1/output_source_priority", "value": "Utility first"}'
Response
{"topic": "inverter_1/output_source_priority", "result": "ok"}
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
passwordstringDevice password.
tokenstringBearer token, as an alternative to password.
Request
ws://192.168.0.100/api/socket/websocket?password=<password>

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:

TopicDescription
total/pv_powerCombined PV power across all inverters (W)
total/load_powerTotal load power (W)
total/grid_powerGrid power, negative = export (W)
total/battery_powerBattery power, negative = charging (W)
total/battery_state_of_chargeBattery state of charge (%)
inverter_1/device_modeCurrent inverter mode
battery_1/voltageBattery 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.