API REST
Provides RESTful HTTP/JSON access to OpenEMS Edge channels and JSON-RPC methods. Enables external systems to monitor and control OpenEMS via standard HTTP protocol.
Overview
The REST API Controller exposes OpenEMS channels and configuration as REST endpoints. External clients (web applications, mobile apps, scripts) can:
-
Read Channels: Query current values of any channel via GET requests
-
Write Channels: Set channel values via POST requests (write-enabled mode only)
-
Regex Queries: Use regular expressions to query multiple channels in one request
-
JSON-RPC Methods: Execute remote procedure calls for complex operations
-
Configuration Management: Query and update component configuration
-
Component Discovery: Get full Edge configuration with components and channels
-
HTTP/JSON REST endpoints
-
Regular expression channel queries
-
Basic authentication (password-based)
-
Read-only or read-write access modes
-
Configurable port (default 8084)
-
Connection rate limiting
-
Write timeout protection
-
Debug logging mode
Components
Controller.Api.Rest.ReadWrite
HTTP REST server with read-write access to channels and JSON-RPC methods. External clients can read all channels and write to channels via POST requests.
Controller.Api.Rest.ReadWrite
Implements:
-
io.openems.edge.controller.api.rest.readwrite.ControllerApiRestReadWrite -
io.openems.edge.controller.api.rest.RestApi -
io.openems.edge.controller.api.Controller -
io.openems.edge.common.component.OpenemsComponent
| Parameter | Description | Type | Default |
|---|---|---|---|
|
Unique component identifier |
String |
|
|
Human-readable component name |
String |
(component-id) |
|
Enable/disable the controller |
Boolean |
|
|
HTTP server port |
Integer |
|
|
Maximum concurrent HTTP connections |
Integer |
|
|
Timeout for channel writes (seconds) |
Integer |
|
|
Enable verbose debug logging |
Boolean |
|
Base URL
All REST requests use this base URL pattern:
http://[username:password@]<IP>:<PORT>/rest
-
username: Always optional; if omitted, can be replaced withx -
password: User password (required for authentication) -
<IP>: Edge machine IP address or hostname -
<PORT>: Configured port (default 8084) -
/rest: REST API path prefix
REST Endpoints
GET /rest/channel/<Component-ID>/<Channel-ID>
Read the current value of a single channel.
Parameters
-
<Component-ID>: Component identifier (e.g.,_sum,ess0,meter0) -
<Channel-ID>: Channel identifier (e.g.,ActivePowerL1,Soc)
Response
{
"type": "INTEGER",
"accessMode": "RO",
"text": "",
"unit": "%",
"value": 50
}
-
type: Data type (INTEGER, LONG, FLOAT, STRING, STATE, BOOLEAN) -
accessMode: Read/Write permissions (RO, RW) -
text: Human-readable description -
unit: Measurement unit (W, V, %, A, Hz, etc.) -
value: Current channel value
GET /rest/channel/<Regex-Component>/<Regex-Channel>
Query multiple channels using regular expressions.
Parameters
-
<Regex-Component>: Regular expression pattern for component IDs (e.g.,.*for all) -
<Regex-Channel>: Regular expression pattern for channel IDs (e.g.,Active.*Powerfor active power channels)
Response
Returns array of matching channels:
[
{
"address": "pvInverter0/ActivePower",
"type": "INTEGER",
"accessMode": "RO",
"text": "",
"unit": "W",
"value": 90
},
{
"address": "meter0/ActivePower",
"type": "INTEGER",
"accessMode": "RO",
"text": "",
"unit": "W",
"value": 465
},
{
"address": "ess0/ActivePower",
"type": "INTEGER",
"accessMode": "RW",
"text": "",
"unit": "W",
"value": -250
}
]
POST /rest/channel/<Component-ID>/<Channel-ID>
Write a value to a writable channel (read-write mode only).
Example Requests
POST http://x:user@localhost:8084/rest/channel/io0/Relay1
Content-Type: application/json
{
"value": true
}
POST http://x:user@localhost:8084/rest/channel/ess0/SetActivePowerEquals
Content-Type: application/json
{
"value": 5000
}
POST http://x:user@localhost:8084/rest/channel/heatpump0/Start
Content-Type: application/json
{
"value": false
}
JSON-RPC Endpoints
POST /rest/jsonrpc
Execute JSON-RPC method calls.
All JSON-RPC requests are sent as POST requests with JSON body. Standard JSON-RPC fields id and jsonrpc are optional.
getEdgeConfig
Get complete Edge configuration including components, channels, and their metadata.
Response
{
"components": [
{
"id": "_sum",
"alias": "Summary",
"type": "io.openems.edge.common.sum.Sum",
"channels": [
{
"id": "GridActivePower",
"type": "INTEGER",
"unit": "W",
"accessMode": "RO"
}
]
},
{
"id": "ess0",
"alias": "Battery System",
"type": "io.openems.edge.ess.api.ManagedSymmetricEss",
"channels": [...]
}
]
}
Configuration Examples
{
"id": "ctrlApiRest0",
"alias": "REST API Server",
"enabled": true,
"port": 8084,
"connectionlimit": 10,
"apiTimeout": 60,
"debugMode": false
}
{
"id": "ctrlApiRest0",
"alias": "REST API (Read-Only)",
"enabled": true,
"port": 8080,
"connectionlimit": 50,
"apiTimeout": 30,
"debugMode": false
}
Authentication
Basic HTTP authentication is used. Format:
Authorization: Basic base64(username:password)
Usernames are typically:
* user (default unprivileged)
* admin (admin privileges)
* x (if username is omitted)
Password must match configured user password in OpenEMS.
Error Responses
| Status | Meaning |
|---|---|
200 OK |
Request successful |
400 Bad Request |
Invalid JSON format or missing required parameters |
401 Unauthorized |
Authentication failed (invalid credentials) |
403 Forbidden |
Access denied (insufficient permissions or read-only mode) |
404 Not Found |
Component or channel not found |
408 Request Timeout |
Channel write operation timed out |
500 Internal Server Error |
Server error |
{
"error": "Channel not found: component/channel"
}
Client Examples
cURL
curl -u x:user http://localhost:8084/rest/channel/_sum/EssSoc
curl -X POST -u x:user \
-H "Content-Type: application/json" \
-d '{"value": 5000}' \
http://localhost:8084/rest/channel/ess0/SetActivePowerEquals
curl -u x:user http://localhost:8084/rest/channel/.*/Active.*Power
curl -X POST -u x:user \
-H "Content-Type: application/json" \
-d '{"method":"getEdgeConfig","params":{}}' \
http://localhost:8084/rest/jsonrpc
JavaScript/Fetch
fetch('http://localhost:8084/rest/channel/_sum/EssSoc', {
headers: { 'Authorization': 'Basic ' + btoa('x:user') }
}).then(r => r.json()).then(data => console.log(data.value));
fetch('http://localhost:8084/rest/channel/ess0/SetActivePowerEquals', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa('x:user'),
'Content-Type': 'application/json'
},
body: JSON.stringify({ value: 5000 })
});
Testing Tools
Popular tools for testing REST APIs:
-
Postman - Desktop client for REST testing
-
Restlet Client - Chrome extension
-
Insomnia - REST client alternative to Postman
-
curl- Command-line HTTP client