Integration examples#
This page focuses on how partner teams typically use the project in real integration work.
Example 1: simple service script#
Use ClientInterfaceAPI as a context manager, wait until data is available, then read the values you care about.
from ur_client import ClientInterfaceAPI
with ClientInterfaceAPI("192.168.0.10", interface_name="primary_ro") as api:
api.wait_until_ready(timeout=5.0, minimum_packet_count=1)
print(api.get_values(
"robot.mode",
"robot.safety_mode",
"tcp.pose.x",
"errors.latest.error_code",
))
Example 2: HMI-oriented periodic polling#
Many partner products already have a GUI loop or a timed update cycle. In that case, read only the fields you want to show.
display_values = api.read_many(
"robot.mode",
"tcp.pose.x",
"tcp.pose.y",
"tcp.pose.z",
"errors.latest.error_code",
"errors.latest.description",
)
That keeps the bridge between the library and the HMI explicit and understandable.
Example 3: continuous watch loop#
watch() is a good fit when you want a compact iterable interface for a background worker or a bridge component.
for item in api.watch(
"robot.mode",
"errors.latest.error_code",
interval=0.5,
):
forward_to_internal_bus(item)
Example 4: app-first exploration, API-second integration#
A strong partner workflow is:
use the app to discover the fields and messages your robot actually produces,
decide which value paths are important for your product,
move only those paths into your API code.
This avoids overexposing data and helps teams keep a clean contract between the robot-facing layer and the product-facing layer.
Example 5: historical error rendering#
If your product stores only error codes, you can still render richer operator-facing text later.
code = database_row["error_code"]
info = api.lookup_error(code)
if info:
show_error_card(
code=info["error_code"],
description=info["description"],
explanation=info["explanation"],
suggestion=info["suggestion"],
)
Included example file#
The repository includes example_api.py as a starting point. It demonstrates connection, selected-value reads, and a simple watch loop.