UniFi API client 2.4.0
Support for the Network Application 11.x statistics engine, with no changes to existing behaviour.
Background
Network Application 11.0 (UniFi OS 6.0 or newer; no longer available for the self-hosted Network Server)
moved all time-series statistics to a new engine and removed several legacy endpoints. Statistics history
is not migrated: the new store starts at the moment of the 11.x upgrade. On 10.x and older nothing changes.
New methods
get_stats_source()– returnsLEGACY(10.x, thestat/report/*endpoints are populated) or
MODERN(11.x, usestat_series()). Controllers older than 10.x do not have the endpoint and throw a
JsonDecodeException; treat that asLEGACY.list_stat_schemas()– the 28 schemas of the new engine with their keys, value fields and nested groups.stat_series()– time series from the new engine: schema, period (HOUR/DAY5-minute buckets,
WEEKhourly,MONTH8-hour), end timestamp, optional start timestamp (11.0.89+, mutually exclusive
with period), filter in the official API grammar, projection (values(...),nested(...)) and
noGaps. Arguments are validated client-side withInvalidArgumentException.list_aggregated_dashboard()– the data behind the Network Application dashboard, the replacement for
list_dashboard(). Works on 10.x as well.STAT_SERIES_PERIODSconstant.
Behaviour on Network Application 11.x (documented, methods unchanged)
- Always return an empty array:
stat_5minutes_site()…stat_monthly_gateway()(all 16 interval report
methods) andstat_speedtest_results(). Usestat_series(). - Throw a
ControllerErrorExceptionbecause the endpoint was removed:list_dashboard()(use
list_aggregated_dashboard()),list_events()(useget_system_log('all')),stat_ips_events()(use
get_system_log('threat-alert')),list_alarms()andcount_alarms()(useget_system_log('critical')),
check_controller_update()(stat_sysinfo()still reportsupdate_available), and thetriggers
class ofget_system_log(). - Unaffected: sessions, guests, authorizations, vouchers, devices, clients, health, system log and all
configuration endpoints.
Documentation
- API reference: new "Statistics" section with the schema list, a mapping from the legacy report methods to
the new schemas, usage examples, and notes on every affected method. get_system_log():allandcriticalclasses and category filtering documented.- README: Network Application 11.x section; supported versions now include Network 11.x (11.0.89
confirmed) and UniFi OS 6.x (6.0.13 confirmed). - New example
examples/stat_series.phpshowing source detection and switching.
Compatibility
PHP 7.4 or newer, unchanged. Verified on PHP 7.4.33 against Network Application 11.0.83 and 11.0.89
(direct and through the Site Manager connector) and 10.6.106.