github Art-of-WiFi/UniFi-API-client v2.4.0
API client class v2.4.0

3 hours ago

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() – returns LEGACY (10.x, the stat/report/* endpoints are populated) or
    MODERN (11.x, use stat_series()). Controllers older than 10.x do not have the endpoint and throw a
    JsonDecodeException; treat that as LEGACY.
  • 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/DAY 5-minute buckets,
    WEEK hourly, MONTH 8-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 with InvalidArgumentException.
  • list_aggregated_dashboard() – the data behind the Network Application dashboard, the replacement for
    list_dashboard(). Works on 10.x as well.
  • STAT_SERIES_PERIODS constant.

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) and stat_speedtest_results(). Use stat_series().
  • Throw a ControllerErrorException because the endpoint was removed: list_dashboard() (use
    list_aggregated_dashboard()), list_events() (use get_system_log('all')), stat_ips_events() (use
    get_system_log('threat-alert')), list_alarms() and count_alarms() (use get_system_log('critical')),
    check_controller_update() (stat_sysinfo() still reports update_available), and the triggers
    class of get_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(): all and critical classes 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.php showing 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.

Don't miss a new UniFi-API-client release

NewReleases is sending notifications on new releases.