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:
Parameter | Type | Explanation |
---|---|---|
$request_id | Integer | A unique ID to identify the request. Could be 1 . |
$session_id | String | A 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. |
$object | String | The object to call, for example ixon.ui.overview . |
$method | String | The object's method to call, for example get . |
$args | Object | The arguments to pass to the object's method. Use an empty object ({ } ) when no arguments are needed. |
Response:
Parameter | Type | Explanation |
---|---|---|
$request_id | Integer | The ID of the request. |
$response_code | Integer | The response code. Could be any of the following:0 : Success1 : Invalid command2 : Invalid argument3 : Method not found4 : Not found5 : No response6 : Permission denied7 : Request timed out8 : Operation not supported9 : Unknown error10 : Connection failed |
$response_data | Object | The call's response. |
Calls
The following calls are supported:
Name | Object | Method | Args | Authentication Required |
---|---|---|---|---|
Login | session | login | { "username": String, "password": String, "timeout": Integer } | No |
Overview | ixon.ui.overview | get | { } | No |
Configuration | ixon.ui.configuration | get | { } | Yes |
set | { "configuration": Object } | Yes | ||
Account | ixon.ui.account | password_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.
Updated about 1 year ago