Skip to main content

9 API

The firmware of the WCC Lite features a built-­in API which is accessible via the web interface.

The API (as of version 1.2.0) implements API key authorization, that is generated on the first boot of the device. The authorization can be enabled or disabled and the API key can be changed via the web configuration interface at Services → API.

Authentication

API key authentication is enabled by default and it generates a random 12-character long key. The key is stored in the same uci configuration as API.

To change the API key via the interface, it must be equal to or longer than 12 characters.

When API authentication is enabled WCC Lite+ checks if the "apiKey" header exists in the request and then validates its value against the one in the configuration. If the value is correct it continues with the API request, if the apiKey is incorrect or doesn't exist it returns an error response 401 with the message.

{

    "error""Unauthorized access."
}

 

Individual API endpoints can be enabled or disabled via the web configuration interface at Services->API.

All endpoints are disabled by default.

All endpoints are disabled by default. Available API endpoints are shown in the table below.

Path Description

Request body

(encoded as "multipart-form-data")

Response body example

(json format)

/api/version Version of the API
{
    "api_version": "2",
    "api_patch": "1",
    "sync_version": "lite1"
}
/api/actions  List of available points

/api/syncVersion A version of the sync service

/api/sync

Protocol hub configuration upload
(key name="file").

Returns excel-utility output )*

{
    "file""config.xlsx"
}

/api/syslog  Prints out the syslog

/api/systemInfo General system info

/api/gsmInfo  GSM modem information

/api/devices  List of configured devices

/api/device/info  Returns configured device information.
(key name="device_alias")**
{
    "device_alias""INV1"
}
{
    "Devices": [
        {
            "device_alias": "INV1",
            "name": "INV1",
            "protocol": "modbus rtu"
        }
    ]
}
/api/device/tags

List of tags of a particular configured device.

(key name="device_alias")**

{
    "device_alias": "INV1"
}

{
    "total_signals": "7",
    "signals": [
        {
            "signal_name": "Active power",
            "source_device_alias": "",
            "input_topic": "tag/INV1/P/rin",
            "output_topic": "tag/INV1/P/out",
            "signal_alias": "P"
        },

...

/api/device/tag/value

Returns tags value, name, timestamp, and flags of a particular device. 
(key name="device_alias",

key name="signal_alias")**

{
    "device_alias": "INV1",
    "signal_alias": "P"
}
{
    "total_signals": "1",
    "signal_values": [
        {
            "signal_name": "Active power",
            "value": "5.9589999999999996",
            "timestamp": "1708000203824",
            "flags": ""
        }
    ]
}
/api/tags  List of configured tags

/api/sysupgrade  Firmware upgrade. (key name="file")* {
    "file": "1.8.0-rtu.sysupgrade"
}

If successfully started the upgrade:

{
    "message": "Upgrade started"
}
If failed to begin:
{
    "message": "Failed to begin upgrade"
}
If firmware validation failed:
{
    "message": "Failed to validate image"
}

* Endpoints accepting files (requires WCC Lite Firmware version 1.8 or newer)
** Endpoints accepting field data (requires WCC Lite firmware version 1.8 or newer)

The API accepts data and files as POST requests encoded as ”multipart/form­data”.

If API authorization is enabled, you must add a header "apiKey" with the correct key.