Introduction

📘

The Router API works on an IXrouter running firmware 3.19 or later.

The Router API can be used to get an overview of the state of the IXrouter, get configuration details, and make configuration changes. Example use cases are integrating the router into custom tooling or existing ERP systems. The local web interface of the IXrouter also makes use of the Router API. The Router API follows JSON-RPC 2.0 to make a remote procedure call (RPC) and is available over HTTP by making a POST request to the /ubus endpoint.

The documentation examples assume the router's LAN IP address is 192.168.140.1.

Format

The format is as follows:

curl --request POST \
     --url "192.168.140.1/ubus"
     --data '
     {
         "jsonrpc": "2.0",
         "id": $request_id,
         "method": "call",
         "params": [
             "$session_id",
             "$object",
             "$method",
             { $args }
         ]
     }'
{
    "jsonrpc": "2.0",
    "id": $request_id,
    "result": [
        $response_code,
        { $response_data }
    ]
}

Request:

ParameterTypeExplanation
$request_idIntegerA unique ID to identify the request. Could be 1.
$session_idStringA valid session ID that has permissions to access the object and method. Use 00000000000000000000000000000000 for calls that do not require authentication, otherwise use a session ID obtained by logging in, see How to authenticate to the API.
$objectStringThe object to call, for example ixon.ui.overview.
$methodStringThe object's method to call, for example get.
$argsObjectThe arguments to pass to the object's method. Use an empty object ({ }) when no arguments are needed.

Response:

ParameterTypeExplanation
$request_idIntegerThe ID of the request.
$response_codeIntegerThe response code. Could be any of the following:
0: Success
1: Invalid command
2: Invalid argument
3: Method not found
4: Not found
5: No response
6: Permission denied
7: Request timed out
8: Operation not supported
9: Unknown error
10: Connection failed
$response_dataObjectThe call's response.

Calls

The following calls are supported:

NameObjectMethodArgsAuthentication Required
Loginsessionlogin{ "username": String, "password": String, "timeout": Integer }No
Overviewixon.ui.overviewget{ }No
Configurationixon.ui.configurationget{ }Yes
set{ "configuration": Object }Yes
Accountixon.ui.accountpassword_set{ "password": String }Yes

Refer to the individual pages for details. Some calls require authentication, see How to authenticate to the API.

📘

TIP

The following response indicates you did not supply a valid session ID:

{
    "jsonrpc": "2.0",
    "id": 1,
    "error": {
        "code": -32002,
        "message": "Access denied"
    }
}

This can happen if you supply the null-session ID to a call that requires authentication, or your session ID has expired. Use the Login call again to obtain a new session ID.