Backend HTTP API
The Bandix backend (bandix, from the separate openwrt-bandix project) serves a JSON HTTP API. LuCI Bandix never talks to it from the browser: the rpcd plugin calls it with curl on the router itself. This page lists every endpoint the plugin uses, with the parameters and bodies it sends.
Note: This repository contains only the client side of this API. Request shapes below are taken from the rpcd plugin; response fields are those the plugin and the LuCI views read. The backend may return more fields, and its exact behavior (filter matching, validation) is defined in the backend project.
Address
The plugin builds the base URL from UCI when it starts:
http://<bandix.general.host>:<bandix.general.port>
host value |
Address used |
|---|---|
empty or 0.0.0.0 |
127.0.0.1 |
:: |
[::1] |
other IPv6 address (contains :) |
[<address>] |
| anything else | as is |
The port defaults to 8686 when empty. The project's architecture notes state that release builds of the backend listen on 127.0.0.1:8686, so the API is not reachable from the LAN by default.
Try it on the router:
curl -s http://127.0.0.1:8686/api/traffic/devices
curl -s http://127.0.0.1:8686/api/version
Conventions
- Responses are JSON objects, normally
{"status": "success", "data": …}. The plugin treats a response containing"status":"success"as success for write calls. - Rates and limits are in bytes per second, sizes in bytes, times in Unix milliseconds unless noted.
rxis download (towards the LAN device),txis upload.- Write calls send
Content-Type: application/json.
Timeouts used by the plugin (connect / total):
| Calls | Timeouts |
|---|---|
| Most GET calls | 2 s / 5 s |
GET /api/traffic/metrics |
1 s / 3 s |
| DNS and usage GET calls | 2 s / 10 s |
GET /api/connection/flows |
2 s / 15 s |
| GeoIP calls | 2 s / 8 s |
| Most write calls | 3 s / 10 s |
DELETE /api/traffic/devices/batch |
3 s / 15 s |
Traffic
GET /api/traffic/devices
Device list with totals and current rates. Optional query parameters start_ms and end_ms restrict the totals to a range. The fields of data.d are listed under getStatus.
GET /api/traffic/metrics
Realtime history. Optional mac. data contains retention_seconds, mac and metrics.
GET /api/traffic/usage/ranking
Query: start_ms, end_ms, network_type (wan, lan, all). See getTrafficUsageRanking.
GET /api/traffic/usage/increments
Query: start_ms, end_ms, aggregation (hourly, daily), mac, network_type. See getTrafficUsageIncrements.
POST /api/traffic/bindings
Sets a hostname binding:
{
"mac": "aa:bb:cc:dd:ee:ff",
"hostname": "living-room-tv"
}
An empty hostname removes the binding.
DELETE /api/traffic/devices
Deletes one device:
{"mac": "aa:bb:cc:dd:ee:ff"}
DELETE /api/traffic/devices/batch
Deletes several devices:
{"macs": ["aa:bb:cc:dd:ee:01", "aa:bb:cc:dd:ee:02"]}
The response's data has deleted, not_found and failed lists. Backends without this endpoint answer 404 or 405.
Rate Limits
GET /api/traffic/limits/schedule
Returns data.limits, a list of rules:
{
"id": "…",
"mac": "aa:bb:cc:dd:ee:ff",
"time_slot": {"start": "19:00", "end": "23:00", "days": [1, 2, 3, 4, 5]},
"wan_rx_rate_limit": 1048576,
"wan_tx_rate_limit": 262144
}
days uses 1 = Monday … 7 = Sunday. A limit of 0 means unlimited.
POST /api/traffic/limits/schedule
Creates a rule. Body: as above, without id.
PUT /api/traffic/limits/schedule
Updates a rule. Body: as above, with id.
DELETE /api/traffic/limits/schedule
{"id": "…"}
GET /api/traffic/rate_limit/whitelist
Returns data.enabled, data.macs, data.default_wan_rx_rate_limit and data.default_wan_tx_rate_limit.
POST /api/traffic/rate_limit/whitelist/enabled
{"enabled": true}
POST /api/traffic/rate_limit/whitelist
DELETE /api/traffic/rate_limit/whitelist
Add or remove an exempt device:
{"mac": "aa:bb:cc:dd:ee:ff"}
POST /api/traffic/rate_limit/default
{"wan_rx_rate_limit": 2097152, "wan_tx_rate_limit": 524288}
Quotas
GET /api/traffic/quotas
Returns data.quotas and data.supports_quota_modes.
POST /api/traffic/quotas
Creates or replaces the quota of a device. setTrafficQuotaConfig always sends all six limits at the top level and in both upload and download, filling unset ones with 0. A directional quota of 1 GiB upload and 5 GiB download per day is sent as (whitespace added):
{
"mac": "aa:bb:cc:dd:ee:ff",
"mode": "directional",
"minute_bytes": 0, "hourly_bytes": 0, "daily_bytes": 0,
"weekly_bytes": 0, "monthly_bytes": 0, "total_bytes": 0,
"upload": {
"minute_bytes": 0, "hourly_bytes": 0, "daily_bytes": 1073741824,
"weekly_bytes": 0, "monthly_bytes": 0, "total_bytes": 0
},
"download": {
"minute_bytes": 0, "hourly_bytes": 0, "daily_bytes": 5368709120,
"weekly_bytes": 0, "monthly_bytes": 0, "total_bytes": 0
}
}
The rules for mode, upload and download are on the Traffic Quotas page. The legacy setTrafficQuota method sends only mac and the six combined limits.
DELETE /api/traffic/quotas
{"mac": "aa:bb:cc:dd:ee:ff"}
Connections
GET /api/connection/devices
Connection counters, global (data.g) and per device (data.d). See getConnection.
GET /api/connection/flows
Query: ip, protocol, state, page, page_size, and geoip=1 (added by the plugin whenever paging is used). Returns a page of flows in data.items with total, page, page_size, total_pages and a geoip lookup table keyed by address.
GeoIP
GET /api/geoip/status
GeoIP state: whether lookups are enabled, installed databases, current job and its phase, storage figures, and upload_max_bytes.
POST /api/geoip/manage
| Body | Effect |
|---|---|
{"action":"download","profile":"country"} |
Download a database profile (country, country_asn, city, city_asn) |
{"action":"enable","enabled":true} |
Turn lookups on or off |
{"action":"cancel"} |
Cancel a running download |
{"action":"delete"} |
Delete installed databases |
{"action":"import"} |
Import /tmp/bandix-geoip-upload.mmdb |
DNS
GET /api/dns/queries
Query: domain, device, is_query (true/false), dns_server, query_type, page, page_size. Returns data.queries, data.total, data.total_pages.
GET /api/dns/stats
Returns data.stats with counts, response times and top lists. See getDnsStats.
Version
GET /api/version
Used by getVersion only when the backend package version cannot be read from the package database. The plugin reads version or data.version.
Query-String Encoding
The plugin does not fully URL-encode query parameters: it only replaces spaces with %20 (in ip, protocol, state, mac, domain, device, dns_server and query_type). A filter value containing &, #, ? or + is therefore passed incorrectly. Use plain text in filters.