UniFi Network API (v1) — IDS / IPS detections.
Returns events flagged by the gateway's intrusion detection / prevention engine: signature matches, blocked outbound, suspect inbound, etc.
Requires cookie + CSRF authentication. See UnifiApi.Auth.Cookie.
Detection fields
_id,time,datetime,site_idkey—"EVT_IPS_IpsAlert","EVT_IPS_IpsBlocked", ...subsystem—"ips"app_proto— application-layer protocol detectedcatname— Suricata category, e.g."Misc Attack"signature— Suricata signature textsrc_ip,dest_ip,src_port,dst_port,protousgip— gateway IP that observed the eventinner_alert_action—"allowed","blocked"host,srcMAC,dstMAC
Note: Shape mirrors the legacy controller console; field availability depends on which IPS engine is active and the firmware revision.
Summary
Functions
Lists IDS / IPS events.
Returns a lazy stream that auto-paginates IDS / IPS events via
_start / _limit.
Functions
@spec list(Req.Request.t(), String.t(), keyword()) :: {:ok, term()} | {:error, UnifiApi.Error.t()}
Lists IDS / IPS events.
Options
:within_hours—within=N.:limit—_limit=N.:start—_start=N.
@spec stream(Req.Request.t(), String.t(), keyword()) :: Enumerable.t()
Returns a lazy stream that auto-paginates IDS / IPS events via
_start / _limit.
Error contract
A mid-stream error does not raise by default: the stream halts and
yields {:error, %UnifiApi.StreamError{}, last_start} as its final element,
so the enumerable is heterogeneous and Enum.map(stream, & &1["key"])
crashes on a transient 500. Match the tail:
items = Enum.to_list(stream)
case List.last(items) do
{:error, error, cursor} -> {:error, error, cursor}
_ -> {:ok, items}
endPass raise_errors: true to raise UnifiApi.StreamError instead.
Options
:within_hours— passed through to every page aswithin=N.:limit— page size (default 500).:max_pages— halt after this many successful pages (default: unbounded).:max_items— halt once this many detections have been yielded; the final page is truncated to fit (default: unbounded).:raise_errors— whentrue, raiseUnifiApi.StreamErroron a mid-stream error instead of yielding{:error, reason, last_start}as the final element (default:false).
:max_pages, :max_items and :raise_errors are forwarded verbatim
to UnifiApi.Client.stream_v1/3 and behave exactly as they do in
UnifiApi.Client.stream/3. Any other key raises ArgumentError.
Examples
# The 100 most recent detections in the last 12 hours
UnifiApi.Network.IDS.stream(authed, "default", within_hours: 12, max_items: 100)
|> Enum.to_list()