Discovery service API

The discovery service API allows you to get a list of resources available to configure on a machine based on the hardware that is connected to or part of the machine. Discoverable resources can include components that are physically connected to the machine, as well as components that are available on the machine’s local network.

The discovery service supports the following methods:

Method NameDescription
DiscoverResourcesGet a list of component configs of all resources available to configure on a machine based on the hardware that is connected to or part of the machine.

Establish a connection

To get started using Viam’s SDKs to connect to and control your machine, go to your machine’s page on the Viam app, navigate to the CONNECT tab’s Code sample page, select your preferred programming language, and copy the sample code.

To show your machine’s API key in the sample code, toggle Include API key.

When executed, this sample code creates a connection to your machine as a client.

The following code examples assume that you have a machine configured with a Discovery service.

from viam.services.discovery import DiscoveryClient
import (
  "go.viam.com/rdk/services/discovery"
)

API

DiscoverResources

Get a list of component configs of all resources available to configure on a machine based on the hardware that is connected to or part of the machine.

Parameters:

  • extra (Mapping[str, Any]) (optional): Extra options to pass to the underlying RPC call.
  • timeout (float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.

Returns:

Example:

my_discovery = DiscoveryClient.from_robot(machine, "my_discovery")

# Get the discovered resources
result = await my_discovery.discover_resources(
    "my_discovery",
)
discoveries = result.discoveries

For more information, see the Python SDK Docs.

Parameters:

  • ctx (Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
  • extra (map[string]interface{}): Extra options to pass to the underlying RPC call.

Returns:

For more information, see the Go SDK Docs.