UnifiApi.Network.Topology (UnifiApi v0.4.0)

Copy Markdown View Source

UniFi Network API (v2) — site topology graph.

Returns the physical and logical connections the controller has inferred between gateway, switches, APs, and uplink-attached clients — the same data behind the dashboard's topology map.

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

Response shape

An array of nodes, each with at least:

  • id, name, mac, model
  • type"gateway", "switch", "ap", "client"
  • state"connected", "disconnected", "pending"
  • parent — id of the upstream node (gateway has none)
  • parentMac, parentPort — for switch- and AP-attached nodes
  • uplinkType"wire", "wireless"

Note: This endpoint is available on UniFi Network 7.x+. Field shapes track the v2 schema and may shift across firmware revisions.

Summary

Functions

Returns the site topology graph.

Functions

get(client, site_id)

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

Returns the site topology graph.

Examples

{:ok, nodes} = UnifiApi.Network.Topology.get(client, "default")

# Find the gateway
Enum.find(nodes, &(&1["type"] == "gateway"))

# Group by parent
nodes
|> Enum.group_by(& &1["parent"])