Zodiac WX - REST API Overview

The Zodiac WX provides a comprehensive set of REST API that can be used to retrieve system information as well as view and configure system settings. There are a number of ways to access these APIs however the simplest is using cURL, a command line utility available for most operating systems. 

To use the REST APIs you need to provide 4 values: a URL,  the method, parameters and a authorisation token. The URL consist of the IP address or DNS name of your Zodiac WX and a path, which varies based on the type of command you are issuing. The next 2 values are the method, which is the command you want to run and the parameters you want to pass to it. The final value is a authorisation token which is required by each call to ensure you are allowed to make that call and is provided by the Zodiac WX when you first authenticate, so let's do that now.

To authenticate and receive a authorisation token, run the following command and substitute the username / password / IP address values for your own:

curl --data-binary '{"params": ["username", "password"], "jsonrpc": "2.0", "id": 1, "method": "login"}' -H 'content-type: application/json;' https://xxx.xxx.xxx.xxx/cgi-bin/luci/rpc/auth

For example, using the the default configuration settings the command would be:

curl --data-binary '{"params": ["admin", "admin"], "jsonrpc": "2.0", "id": 1, "method": "login"}' -H 'content-type: application/json;' https://192.168.1.1/cgi-bin/luci/rpc/auth

The response will include an authorisation token (example in bold below) that is required for all future REST calls. Tokens are unique per authentication request, can not be reused and will timeout after 5 minutes.

{"id" : 1 , "jasonrpc" : "2.0" , "result" : "<your authorisation token>"}

To then make a configuration call you add the authorisation token you received on to the end of the URL. For example to retrieve the WAN IP Address you would use the method "get", the parameter "network.wan.ipaddr", the URL "/cgi-bin/luci/rpc/uci" and then add "?auth=" with your authorisation token on the end. Like this:

curl --data-binary '{"params": ["network.wan.ipaddr"], "jsonrpc": "2.0", "id": 1, "method": "get"}' -H 'content-type: application/json;' https://192.168.1.1/cgi-bin/luci/rpc/uci?auth=<your authorisation token>

which will return: {"id" : 1 , "jasonrpc" : "2.0" , "result" : "10.0.1.71"}

When setting a configuration value you use the "set" method and add the value to the parameters, for example:

curl --data-binary '{"params": ["network.wan.ipaddr=192.168.1.1"], "jsonrpc": "2.0", "id": 1, "method": "set"}' -H 'content-type: application/json;' https://192.168.1.1/cgi-bin/luci/rpc/uci?auth=<your authorisation token>

which will return if successful: {"id" : 1 , "jasonrpc" : "2.0" , "result" : true}

Finally, to save any updated settings you must call the "commit" method using the config section as the parameter, in this case "network":

curl --data-binary '{"params": ["network"], "jsonrpc": "2.0", "id": 1, "method": "commit"}' -H 'content-type: application/json;' https://192.168.1.1/cgi-bin/luci/rpc/uci?auth=<your authorisation token>

which will return if successful: {"id" : 1 , "jasonrpc" : "2.0" , "result" : true}

Lists of the available commands are provided in the other KB articles, based on the command type.