Skip to main content

Overview

Seam provides a universal API to connect and control many brands of devices. This guide provides a rapid introduction to connecting your UniFi Protect cameras to Seam, retrieving them as devices, receiving their motion events, and retrieving event clips. Seam reaches UniFi Protect on the local network through a Seam Bridge. To learn more about other device brands supported by Seam, head over to our integration page.
UniFi Protect cameras are in beta. Behavior and API shapes may change before general availability.

1 — Install Seam SDK

Seam provides client libraries for many languages, such as JavaScript, Python, Ruby, PHP, and others, as well as a Postman collection and OpenAPI spec.
Once installed, sign up for Seam to get your API key, and export it as an environment variable:
This guide uses a Sandbox Workspace. Only virtual devices can be connected. If you need to connect a real UniFi console, use a non-sandbox workspace and API key.
UniFi Protect is a new provider. Use a Seam SDK version that includes it, or call the endpoints with the cURL or Go examples, which use plain HTTP requests.

To use UniFi Protect through the Seam API, you must first authorize your Seam workspace to reach the console. To do so, Seam provides Connect Webviews: pre-built UX flows that walk you through pairing a Seam Bridge and entering the console’s connection details. Include unifi_protect in the Connect Webview’s accepted_providers list.

Request a Connect Webview

Authorize Your Workspace

Navigate to the URL returned by the Webview object. Since you are using a sandbox workspace, you don’t need to install Seam Bridge. Continue past the Seam Bridge instructions, submit the prefilled sandbox pairing code, and then enter the UniFi Protect sandbox console details below:
  • Console address: unifi.test
  • HTTPS port: 443
  • Protect API key: unifi-protect-test-api-key
  • Local user for event recordings (optional): protect-viewer
  • Local user password (optional): protect-viewer-password
Confirm the Connect Webview was successful by querying its status:

3 — Retrieve the UniFi Protect Cameras

After a UniFi console is linked with Seam, each camera adopted by that console is a device with the unifi_protect_camera device type. List the devices for the connected account. The top-level can_stream_live_video capability flag is true when the camera supports live video and is online. The console and its paired Seam Bridge must both be online. Check the flag again immediately before opening a live view.

4 — Receive Motion Events

When UniFi Protect detects motion on a connected camera, Seam creates a camera.activated event with activation_reason set to motion_detected. If UniFi Protect reports a smart detection, the event also has a motion_sub_type: human, vehicle, package, or other. To receive these events as they happen, set up a webhook. You can also list events for the camera.
Verify motion events against a real console in a non-sandbox workspace.
Example camera.activated event:

5 — Retrieve Event Clips

If you enter a local-only user with View Only Protect access when you connect a real console, Seam retrieves a 20-second clip and a thumbnail for each motion event from the console’s recordings. The event’s media_ids list both. Fetch each one with /media/get. The returned url expires within minutes. In Seam’s testing, a clip was available about 30 seconds after the motion started. If the media is not yet available, call /media/get again later.
The sandbox console accepts the sandbox local user so that you can test the Connect Webview. Test clips against a real console. For the full flow, see Retrieve Event Media and UniFi Protect event clips.

6 — Stream Live Video

Before streaming a UniFi Protect camera’s live video to a browser over WebRTC, check that its can_stream_live_video capability flag is true. The flag is false while the console or its Seam Bridge is offline. Live view uses a client session token scoped to the camera, so your users’ browsers never see your API key. The first live view of a camera turns on that camera’s low-quality RTSPS stream in UniFi Protect. The sandbox live view plays a test pattern. For the full flow and session errors to handle, see Stream Live Video.

Next Steps

Now that you’ve completed this guide, you can try to connect a real UniFi console. To do so, make sure to switch to a non-sandbox workspace and API key, as real devices cannot be connected to sandbox workspaces. See the UniFi Protect Setup Guide for the Seam Bridge, API key, and local user steps. In addition, if you’d like to explore other aspects of Seam, here is a list of helpful resources: If you have any questions or want to report an issue, email us at support@seam.co.