WebSocket API Reference
Overview
The WebSocket API provides real-time topology updates.
All endpoints:
Use JSON-encoded messages on the wire. The payload examples below are shown in JavaScript-style notation with inline comments for readability.
Push real-time updates after the connection is established.
Do not accept client messages: any data sent from the client is ignored.
Connection Endpoints
1. Topology Updates
Connection URL:
wss://<host>/ws/network-topology/topology/<topology_id>/
In local development or other non-TLS setups, the ws:// scheme may be
used instead of wss://.
Scope
Real-time updates for a single topology identified by <topology_id>.
Client Message
The endpoint does not currently expose a request/response message for retrieving the current state on demand. Messages are delivered when an update event occurs.
Warning
Any message sent by the client is ignored.
Real-time Updates
When a topology update is broadcast, the server sends a JSON message with the following structure:
{
"type": "broadcast_topology", // Message type identifier
"topology": {
"...": "topology data" // Current topology representation
}
}
The topology value contains the current topology representation
returned by the application, serialized as JSON.
A simplified example looks like this:
{
"type": "broadcast_topology",
"topology": {
"type": "NetworkGraph", // NetJSON graph type
"protocol": "netjson.org", // NetJSON protocol identifier
"version": "1.0", // NetJSON version
"nodes": [], // Topology nodes
"links": [] // Topology links
}
}
Connected clients receive a new message whenever topology data changes. Based on the current implementation and test coverage, updates are sent when:
Topology properties change.
Nodes are created, updated, or deleted.
Links are created, updated, or deleted.
Relationship with the REST API
The WebSocket endpoint complements the Rest API by providing live topology updates to connected clients.
Use the REST API when you need to create, retrieve, update, delete, or manually submit topology data. Use the WebSocket endpoint when you need to observe changes to an existing topology in real time.