UniteLabs
Use a connector

UniteLabs SDK & REST API

Access connectors programmatically — discover services, explore their modules and actions, and subscribe to live data using the UniteLabs SDK or the REST API.

The UniteLabs UniteLabs SDK and REST API expose the same connector model: services (connectors), modules (features), and actions (commands and properties). Each section below shows both approaches side by side.

This guide covers discovery and subscriptions. For executing commands and reading properties inside an automation script, continue with Calling a Connector.

Prerequisites

  1. Access to the UniteLabs platform
  2. An environment with an installed SDK — see Installation
  3. A connector deployed and connected to your tenant (the thermocycler demo works for these examples)

Authentication

The UniteLabs SDK handles authentication automatically using environment variables. For the REST API you need a Bearer token.

The SDK reads credentials from environment variables. Set them in your .env file:

.env
BASE_URL=your-tenant-base-url
AUTH_URL=your-authentication-url
CLIENT_ID=your-client-id
CLIENT_SECRET=your-client-secret

Then instantiate the client — no token handling required:

from unitelabs.sdk import AsyncApiClient

client = AsyncApiClient()

List connectors

Retrieve all connectors connected to your tenant.

services = await client.list_services()
print(services)
Terminal
(Thermocycler(client=..., id='daa46515-49bc-4a7d-944f-369732edde2e', name='Thermocycler'),)

Get a specific connector

Look up a connector by name or ID.

By name:

thermocycler = await client.get_service_by_name(name="Thermocycler")
print(thermocycler.id)
print(thermocycler.name)

By ID:

thermocycler = await client.get_service(service_id="daa46515-49bc-4a7d-944f-369732edde2e")

Explore modules (features)

A connector's modules are its features — logical groupings of related actions.

print(thermocycler.modules.keys())
Terminal
dict_keys(['sila_service', 'temperature_controller', 'door_controller'])

Explore actions

Each module exposes actions: the individual commands and properties you can call.

print(thermocycler.temperature_controller.actions.keys())
Terminal
dict_keys(['get_target_temperature', 'subscribe_current_temperature', 'set_target_temperature'])

Check the type of an action (PROPERTY, COMMAND, or SENSOR):

print(thermocycler.temperature_controller.get_target_temperature.type)
# PROPERTY

Subscribe to live data

Observable properties (Sensors) and commands stream data continuously. Use subscriptions to receive values as they change.

async for temperature in thermocycler.temperature_controller.subscribe_current_temperature():
    print(temperature)  # prints each new reading as it arrives

Cancel the subscription by breaking out of the loop or using asyncio cancellation.


Next steps

  • Execute commands: read properties and call commands on the instrument from a script: Calling a Connector
  • Liquid handling & robots: additional SDK packages for deck building and liquid transfers: Operate