browse
browse(node_id, filter = NodeClass.Unspecified) — Lists the direct child nodes (first level) of the specified node.
- For pagination of large nodes, please use browse_with_paging + browse_next.
- For path-based batch parsing, please use translate_browse_paths.
Signature
def browse(self,
node_id: str,
filter: NodeClass = NodeClass.Unspecified) -> List[Reference]: ...
def browse_many(self,
node_ids: List[str],
filter: NodeClass = NodeClass.Unspecified) -> List[List[Reference]]: ...
"Reference" Field
| Field | Type | Note |
|---|---|---|
| node_id | str | Child node NodeId |
| browse_name | str | Browse Name |
| display_name | str | Display Name |
| node_class | NodeClass | Child Node Categories |
Reference.to_node(session) Convert to actionable OpcUaNode.
Examples
from darra_opcua import NodeClass
# List all child nodes Boiler1 under this node
children = ua.browse("ns=2;s=Boiler1")
for c in children:
print(f" {c.node_class.name} {c.browse_name} -> {c.node_id}")
# Show only Variable types
vars_ = ua.browse("ns=2;s=Boiler1", filter=NodeClass.Variable)
# View Only Method
methods = ua.browse("ns=2;s=Calculator", filter=NodeClass.Method)
Batch Browse (browse_many)
If you want to view multiple nodes at the same time (for example, when expanding the tree for the first GUI time), do it in one browse_many go RPC:
roots = ["i=85", "i=86"] # Objects / Types
results = ua.browse_many(roots)
for nid, refs in zip(roots, results):
print(f"{nid}:")
for c in refs:
print(f" {c.browse_name}")
If a node fails to load (NodeId error), the corresponding slot returnsEmpty list, Do not throw exceptions; However, if RPC the entire operation fails (the underlying function returns a non-0 value), an exception is thrown OpcUaException.
NodeClass filter
| Value | Includes |
|---|---|
| Unspecified (0) | All |
| Object (1) | Object Only |
| Variable (2) | Variable Only |
| Method (4) | Method Only |
| Object | Variable (bitwise OR) | Combination |
filter It is passed nodeClassMask down as-is as BrowseDescription, so it can be combined using bitwise OR (0 = no restriction).
Exception
OpcUaException(BadNodeIdUnknown) / OpcUaException(BadCommunicationError) etc. A transport failure triggers an exception; a failure in a single child node does not.
Pagination for Large Nodes (ContinuationPoint)
The fixed requestedMaxReferencesPerNode value for a single request Browse at the lower level is 1000, so when there are more than 1000 child nodes, the server returns only the first page and displays ContinuationPoint.browse Neither read nor return ContinuationPoint, and this is the page you get—not "all child nodes."
To view the entire content, use browse_with_paging + browse_next:
page = ua.browse_with_paging("ns=2;s=BigFolder")
all_refs = list(page.references)
while page.continuation_point is not None:
page = ua.browse_next(page.continuation_point)
all_refs.extend(page.references)
How much per time? RPC
browse: 1 time RPC, retrieve only the first page (≤ 1000 records)browse_many: 1 time RPC with N BrowseDescriptions, saving N-1 round trips (Note: "Network round trips reduced from N to 1")browseThe BrowseDescription for this series is fixed as follows: Direction: Forward; Reference Type: References (i=31) including subtypes; resultMask=0x3F — these are not parameters; currently, filtering by direction or reference type can only be done on the client side (seebrowse_filteredthe implementation limitations below).
browse_filtered — Direction + Reference Type Filtering
browse_filtered The goal is to add browse BrowseDirection + reference_type_id + include_subtypes filtering to the basis (Part 4 §5.8.2.2).
def browse_filtered(self,
nid: str,
node_class_filter: NodeClass = NodeClass.Unspecified,
direction: BrowseDirection = None, # None = Process FORWARD as is
reference_type_id: str = None,
include_subtypes: bool = True) -> List[Reference]: ...
Related Structures (Real names listed darra_opcua; members in uppercase):
class BrowseDirection(IntEnum):
FORWARD = 0 # Forward-only (outbound), parent→child
INVERSE = 1 # Reverse only (inbound references), child → parent
BOTH = 2 # Returns results in both directions
Example
from darra_opcua import BrowseDirection, NodeClass
# 1) Forward + Only HierarchicalReferences (i=33)
children = ua.browse_filtered("ns=2;s=Boiler1",
node_class_filter=NodeClass.Variable,
direction=BrowseDirection.FORWARD,
reference_type_id="i=33",
include_subtypes=True)
# 2) Backward parent search
parents = ua.browse_filtered("ns=2;s=Tank.Level",
direction=BrowseDirection.INVERSE)
for p in parents:
print(f"父: {p.browse_name}")
Implementation Limitations (Important)
Python Side: CurrentUniversal Degeneration Cheng browse(nid, node_class_filter), direction / reference_type_id / include_subtypes Will not take effect:
DarraUa_Session_BrowseWithFilterIf missing, it will degrade and trigger a Warning.- Even if this entry point exists, it is currently non-functional (the three filter parameters do not take effect).
So today, we’re really browse_filtered just doing NodeClass filtering, and the direction is always Forward. If you actually want to filter by direction or reference type, retrieve the full set yourself and Reference then filter it on the client side. (The C# side BrowseFiltered has resultMask parameters, and the two languages aren’t entirely consistent.)
Auto-Renew
Python SDK None Built-in automatic page-turning API ( BrowseAll extension methods are available only on the C# side); you can just write your own loop:
def browse_all_refs(ua, node_id, filter=NodeClass.Unspecified):
all_refs = []
page = ua.browse_with_paging(node_id, filter)
all_refs.extend(page.references)
while page.continuation_point is not None:
page = ua.browse_next(page.continuation_point)
all_refs.extend(page.references)
return all_refs