RPC Methods
LuCI Bandix installs an rpcd plugin, /usr/libexec/rpcd/luci.bandix, which registers the ubus object luci.bandix. The LuCI views use it for everything they show or change. You can call the same methods from a shell with ubus call, or remotely through LuCI's JSON-RPC endpoint with a valid session.
Most methods are thin proxies: they build a request to the backend HTTP API with curl, and return the backend's JSON either unchanged or with only its data member.
Calling Methods
List the methods and their declared parameters:
ubus -v list luci.bandix
Call a method:
ubus call luci.bandix getStatus
ubus call luci.bandix getMetrics '{"mac":"aa:bb:cc:dd:ee:ff"}'
The plugin accepts arguments in two shapes: a JSON object with named fields (what ubus call and LuCI send) or a JSON array in parameter order. If no input arrives on standard input within one second, most methods fall back to positional command-line arguments.
Response Conventions
| Situation | Response |
|---|---|
| Proxied call succeeded | The backend's JSON, usually {"status":"success","data":…}, or only its data member (see each method) |
| Plugin-level error | {"success": false, "error": "<message>"} |
| Plugin-level success (write methods that check the backend) | {"success": true, "message": "<message>"} |
| Backend unreachable | {"success": false, "error": "Failed to connect to Bandix service"} for most methods |
The backend address is http://<bandix.general.host>:<bandix.general.port>, with wildcard addresses mapped to loopback (see Configuration).
Method Index
| Method | Parameters | Backend request | ACL |
|---|---|---|---|
getStatus |
start_ms, end_ms |
GET /api/traffic/devices |
read |
getMetrics |
mac |
GET /api/traffic/metrics |
read |
setHostname |
mac, hostname |
POST /api/traffic/bindings |
read |
deleteDevice |
mac |
DELETE /api/traffic/devices |
read |
deleteDevices |
macs |
DELETE /api/traffic/devices/batch |
write |
getTrafficUsageRanking |
start_ms, end_ms, network_type |
GET /api/traffic/usage/ranking |
read |
getTrafficUsageIncrements |
start_ms, end_ms, aggregation, mac, network_type |
GET /api/traffic/usage/increments |
read |
getScheduleLimits |
none | GET /api/traffic/limits/schedule |
read |
setScheduleLimit |
mac, start_time, end_time, days, wan_rx_rate_limit, wan_tx_rate_limit |
POST /api/traffic/limits/schedule |
read |
updateScheduleLimit |
id, mac, start_time, end_time, days, wan_rx_rate_limit, wan_tx_rate_limit |
PUT /api/traffic/limits/schedule |
write |
deleteScheduleLimit |
id |
DELETE /api/traffic/limits/schedule |
read |
getRateLimitWhitelist |
none | GET /api/traffic/rate_limit/whitelist |
read |
setRateLimitWhitelistEnabled |
enabled |
POST /api/traffic/rate_limit/whitelist/enabled |
write |
addRateLimitWhitelist |
mac |
POST /api/traffic/rate_limit/whitelist |
write |
deleteRateLimitWhitelist |
mac |
DELETE /api/traffic/rate_limit/whitelist |
write |
setDefaultRateLimit |
wan_rx_rate_limit, wan_tx_rate_limit |
POST /api/traffic/rate_limit/default |
write |
getTrafficQuotas |
none | GET /api/traffic/quotas |
read |
setTrafficQuotaConfig |
quota |
POST /api/traffic/quotas |
write |
setDirectionalTrafficQuota |
quota |
Alias of setTrafficQuotaConfig |
write |
setTrafficQuota |
mac, minute_bytes … total_bytes |
POST /api/traffic/quotas |
write |
deleteTrafficQuota |
mac |
DELETE /api/traffic/quotas |
write |
getConnection |
none | GET /api/connection/devices |
read |
getConnectionFlows |
ip, protocol, state, page, page_size |
GET /api/connection/flows |
read |
getGeoipStatus |
none | GET /api/geoip/status |
read |
manageGeoip |
action, profile, enabled |
POST /api/geoip/manage |
write |
getDnsQueries |
domain, device, is_query, dns_server, query_type, page, page_size |
GET /api/dns/queries |
read |
getDnsStats |
none | GET /api/dns/stats |
read |
clearData |
none | local: deletes <data_dir>/metrics/* |
read |
restartService |
none | local: /etc/init.d/bandix restart |
read |
getVersion |
none | local package database, then GET /api/version |
read |
getSystemArch |
none | local | read |
checkUpdate |
none | GitHub API | read |
installUpdate |
package_type, download_url |
wget + opkg/apk |
read |
The ACL column shows the lowest access level of the luci-app-bandix ACL that grants the method. "read" methods are also in the write list. See Access Control for why some changing methods are listed under read.
Traffic
getStatus
Returns the device list. Without parameters, totals are lifetime totals; with start_ms and end_ms (Unix milliseconds), totals cover that range. The values null and undefined are ignored.
Returns the backend's data member. If the backend is unreachable or returns no data, the plugin returns {"d":[]} instead of an error.
ubus call luci.bandix getStatus '{"start_ms":1764720000000,"end_ms":1764806399999}'
Each entry of d:
| Field | Meaning |
|---|---|
mac, ip4, ip6, host |
Identity (ip6 is a list) |
conn |
wifi, wired or router |
uplink |
Attachment interface, or empty |
w_ch, w_freq |
Wi-Fi channel and frequency (MHz), 0 if not Wi-Fi |
last |
Last seen, Unix milliseconds |
t_rx_b, t_tx_b / t_rx_r, t_tx_r |
Total download/upload bytes / rates |
w_rx_b, w_tx_b / w_rx_r, w_tx_r |
WAN bytes / rates |
w_rx_l, w_tx_l |
WAN download/upload rate limits |
l_rx_b, l_tx_b / l_rx_r, l_tx_r |
LAN bytes / rates |
rx is download (towards the device) and tx is upload. Rates are bytes per second.
getMetrics
Returns the realtime (1 sample per second) history, for all devices or for one mac. Returns the backend's data member, which contains retention_seconds, mac and metrics. On failure it returns {"retention_seconds":600,"mac":"","metrics":[]}. The curl timeout is short (1 s connect, 3 s total).
getTrafficUsageRanking
| Parameter | Description |
|---|---|
start_ms, end_ms |
Range in Unix milliseconds; omitted means the backend's default |
network_type |
wan, lan or all |
Returns data: start, end, net, cnt, totals t_b, t_rx_b, t_tx_b, and r, a list of {mac, ip4, host, r (rank), pct, t_b, rx_b, tx_b}. On failure, an all-zero object with an empty r.
getTrafficUsageIncrements
| Parameter | Description |
|---|---|
start_ms, end_ms |
Range |
aggregation |
hourly or daily (the Status page sends these) |
mac |
One device; omit for all |
network_type |
wan, lan or all |
Returns data: start, end, agg, net, mac, totals, and inc, a list of intervals. Each interval has start, end, byte increments w_rx_b, w_tx_b, l_rx_b, l_tx_b, and rate statistics with the suffixes _avg, _max, _min, _p90, _p95, _p99 for w_rx, w_tx, l_rx and l_tx.
Devices
setHostname
Sets (or with an empty hostname, removes) a hostname binding for mac.
| Result | When |
|---|---|
{"success":true,"message":"Hostname binding set successfully"} |
Backend response contains "status":"success" |
{"success":false,"error":"API returned error response","response":"…"} |
Backend answered otherwise |
{"success":false,"error":"Failed to set hostname binding"} |
No answer |
"Missing MAC address parameter" / "No input received" |
Bad input |
The hostname is inserted into the JSON body without escaping; avoid " and \.
deleteDevice
Deletes one device and its history. Returns the backend's response as is.
deleteDevices
Deletes up to 1000 devices. macs is a JSON-encoded array as a string:
ubus call luci.bandix deleteDevices '{"macs":"[\"aa:bb:cc:dd:ee:01\",\"aa:bb:cc:dd:ee:02\"]"}'
Validation errors: "Too many MAC addresses" (string longer than 65536 characters), "Invalid MAC array", "Invalid MAC address", "macs must contain between 1 and 1000 MAC addresses". The backend's answer is returned as is, normally {"status":"success","data":{"deleted":[…],"not_found":[…],"failed":[{"mac":…,"message":…}]}}. HTTP 404 or 405 from the backend becomes "Batch deletion is unavailable. Update the Bandix service." The curl time limit is 15 seconds.
Rate Limits
getScheduleLimits
Returns the backend's response, which contains the rules in data.limits. Each rule has id, mac, time_slot (start, end, days) and wan_rx_rate_limit, wan_tx_rate_limit in bytes per second.
setScheduleLimit
Adds a rule. All parameters are required.
| Parameter | Format |
|---|---|
mac |
MAC address |
start_time, end_time |
HH:MM |
days |
JSON array of weekday numbers as a string, 1 = Monday … 7 = Sunday, for example "[1,2,3,4,5]" |
wan_rx_rate_limit, wan_tx_rate_limit |
Bytes per second, 0 = unlimited |
Results: "Schedule limit set successfully", "API returned error response" (with response), "Failed to set schedule limit", "Missing or invalid parameters", "No input received".
updateScheduleLimit
Same as setScheduleLimit, plus the rule id. Sent as PUT. Success message: "Schedule limit updated successfully"; errors "ID is required", "Failed to update schedule limit" and the setScheduleLimit validation messages.
deleteScheduleLimit
Deletes rule id. Success message: "Schedule limit deleted successfully"; errors "Missing id parameter", "Failed to delete schedule limit".
getRateLimitWhitelist
Returns the global rate limit state: enabled, macs (whitelisted addresses), default_wan_rx_rate_limit and default_wan_tx_rate_limit, wrapped in the backend's response.
setRateLimitWhitelistEnabled
enabled: 1, true, TRUE or True turn the global limit on; anything else turns it off. Returns the backend's response.
addRateLimitWhitelist
deleteRateLimitWhitelist
Add or remove one mac from the exemption list. "MAC address is required" if empty. Return the backend's response.
setDefaultRateLimit
Sets the global default limits in bytes per second. Both wan_rx_rate_limit and wan_tx_rate_limit are required ("Missing parameters").
Quotas
getTrafficQuotas
Returns the backend's response: data.quotas (one entry per device with limits, *_used_bytes counters, blocked, mode, and in directional mode upload and download objects) and data.supports_quota_modes.
setTrafficQuotaConfig
Saves a complete quota passed as a JSON string in quota. This is the method the Status page uses. The full validation rules and examples are in Traffic Quotas.
Results: {"success":true,"message":"Traffic quota saved successfully"} when the backend replies with "status":"success", otherwise "Failed to save traffic quota" or one of the validation messages. setDirectionalTrafficQuota is an alias.
setTrafficQuota
Legacy method for combined quotas: mac plus the six limits minute_bytes, hourly_bytes, daily_bytes, weekly_bytes, monthly_bytes, total_bytes, each a non-negative integer and all required ("Quota values must be non-negative integers"). These travel as rpcd integers, which are 32-bit, so values above about 2 GiB cannot be passed this way; use setTrafficQuotaConfig.
deleteTrafficQuota
Deletes the quota of mac. Results: "Traffic quota deleted successfully" or "Failed to delete traffic quota".
Connections
getConnection
Returns the backend's full response (not just data) when bandix.connections.enabled is 1; otherwise "Connection monitoring is not enabled". data holds cnt, last, global counters g (total, tcp, udp, tcp_est, tcp_tw, tcp_cw, last) and per-device entries d with the same counters plus mac, ip4, host.
getConnectionFlows
| Parameter | Description |
|---|---|
ip |
Device IPv4 address |
protocol |
tcp or udp |
state |
Connection state, for example ESTABLISHED |
page, page_size |
Paging; when either is given, the plugin also adds geoip=1 |
Spaces in string parameters are encoded as %20; no other URL encoding is done. The curl time limit is 15 seconds. The response is the backend's, with data.items, total, page, page_size, total_pages and geoip (location data per address). Older backends returned a plain array in data, which the Connections page still accepts.
GeoIP
getGeoipStatus
Returns the backend's GeoIP status (enabled flag, installed databases, profile, job progress, storage figures, upload_max_bytes). Errors become "GeoIP service is unavailable".
manageGeoip
action |
Extra parameters |
|---|---|
download |
profile: country, country_asn, city or city_asn |
enable |
enabled: 1/true or 0/false |
cancel, delete, import |
none |
Anything else returns "Invalid GeoIP action", "Invalid database profile" or "Invalid enabled value". import loads /tmp/bandix-geoip-upload.mmdb, which the LuCI upload writes beforehand.
DNS
getDnsQueries
Requires bandix.dns.enabled=1 ("DNS monitoring is not enabled").
| Parameter | Description |
|---|---|
domain |
Domain filter |
device |
Device filter |
is_query |
true for queries only, false for responses only |
dns_server |
DNS server filter |
query_type |
Record type, for example AAAA |
page, page_size |
Paging |
Returns the backend's response: data.queries, data.total, data.total_pages. Each query has fields such as timestamp_formatted, domain, query_type, is_query, response_time_ms, source_ip, destination_ip, device_name and response_records.
getDnsStats
Requires DNS monitoring. Returns data.stats with total_queries, total_responses, latest_response_time_ms, avg_response_time_ms, min_response_time_ms, max_response_time_ms and the lists top_query_types, top_domains, top_devices, top_dns_servers (each {name, count}).
Service and Maintenance
clearData
Deletes all files in <data_dir>/metrics (data_dir from bandix.general.data_dir, default /usr/share/bandix). Results: "Data cleared successfully", "Metrics directory does not exist", "Failed to clear data".
restartService
Runs /etc/init.d/bandix restart. Results: "Service restarted successfully" or "Failed to restart service".
getVersion
{
"luci_app_version": "0.12.12-r5",
"bandix_version": "Unknown"
}
Illustrative output. Values fall back to Unknown. See Updates and Maintenance.
getSystemArch
Returns {"arch": "<arch>"} from OPENWRT_ARCH in /etc/os-release or uname -m.
checkUpdate
Queries GitHub for both projects and returns a flat object:
| Field | Meaning |
|---|---|
current_luci_version, current_bandix_version |
Installed versions |
latest_luci_version, latest_bandix_version |
Latest release tags without v |
luci_has_update, bandix_has_update |
"1" or "0" (strings) |
luci_update_url, bandix_update_url |
Release page URLs |
luci_release_body, bandix_release_body |
Release notes (Markdown) |
luci_download_url, bandix_download_url |
Matching asset URLs, or empty |
luci_error, bandix_error |
For example "No ipk package found for bandix" |
detected_arch, detected_pkg_manager |
Detection results |
luci_asset_count, bandix_asset_count |
Number of release assets examined |
installUpdate
| Parameter | Description |
|---|---|
package_type |
luci or bandix (informational) |
download_url |
URL of the package to download and install |
Both parameters are required ("Missing package_type or download_url parameter"). Downloads the URL to /tmp (wget, 10-second timeout), runs the package manager's update, installs the file (apk add --allow-untrusted on apk systems) and returns success, step, message/error and the installer output.
Note:
installUpdateinstalls whatever URL it is given. It is meant to be called with the URL thatcheckUpdatefound on GitHub, but the plugin does not enforce that.
Access Control
The ACL file /usr/share/rpcd/acl.d/luci-app-bandix.json defines one ACL group, luci-app-bandix, with a read and a write part. Both grant access to the bandix UCI configuration; the write part additionally grants write access to /tmp/bandix-geoip-upload.mmdb.
Things worth knowing about it:
- The read list includes methods that change state or run commands:
setHostname,deleteDevice,setScheduleLimit,deleteScheduleLimit,clearData,restartServiceandinstallUpdate. A LuCI user who was given only read access to this app can therefore still use them. - Newer methods (
deleteDevices,updateScheduleLimit, the whitelist and default-limit setters, the quota setters,manageGeoip) are in the write list only. - Both lists name methods the plugin does not implement (
getMetricsDay,getMetricsWeek,getMetricsMonth, andgetRateLimitWhitelistEnabledin the write list). They have no effect.
On a single-admin router (the usual case, where root has full access) none of this matters. If you create restricted LuCI users, do not give them the luci-app-bandix ACL unless you trust them with these actions.