UnifiApi.Network.DPI (UnifiApi v0.4.0)

Copy Markdown View Source

UniFi Network API (v1) — deep packet inspection statistics.

Returns per-application and per-category traffic stats, both site-aggregated and per-client.

Requires cookie + CSRF authentication. See UnifiApi.Auth.Cookie.

Use UnifiApi.Network.Resources.list_dpi_categories/1 and list_dpi_applications/1 (integration API, no cookie auth required) to translate the numeric cat and app IDs returned here into human-readable names.

Stats fields (per by_app / by_cat entry)

  • app / cat — numeric ID
  • tx_bytes, rx_bytes, tx_packets, rx_packets
  • clients — number of distinct clients observed using this app/category

Summary

Functions

Returns DPI stats grouped by client (MAC).

Returns site-wide DPI stats grouped by application and category.

Annotates DPI stats with human-readable category and application names.

Functions

by_client(client, site_id)

@spec by_client(Req.Request.t(), String.t()) ::
  {:ok, term()} | {:error, UnifiApi.Error.t()}

Returns DPI stats grouped by client (MAC).

Response is a list with one entry per client containing mac and the same by_app / by_cat shape as by_site/2.

by_site(client, site_id)

@spec by_site(Req.Request.t(), String.t()) ::
  {:ok, term()} | {:error, UnifiApi.Error.t()}

Returns site-wide DPI stats grouped by application and category.

Response is a list of one entry per site with by_app and by_cat arrays.

with_names(dpi_data, opts)

@spec with_names(
  [map()],
  keyword()
) :: [map()]

Annotates DPI stats with human-readable category and application names.

Deprecated in v0.4.0 (removal in v0.5.0): the helper has been lifted to UnifiApi.DPI.Names.with_names/2 — it was a pure data transform living in an HTTP-only module. This function remains as a thin delegation so existing aliases keep working:

# Old (deprecated, removed in v0.5):
UnifiApi.Network.DPI.with_names(dpi, categories: cats, applications: apps)

# New:
UnifiApi.DPI.Names.with_names(dpi, categories: cats, applications: apps)

See UnifiApi.DPI.Names for the full doc and rationale.