Seam provides a universal API to connect and control many brands of IoT devices and systems, including smart locks, access control systems (ACSs), thermostats, and noise sensors.
This guide gives you a rapid introduction to connecting and controlling your 4SUITES lock using the Seam API. For application developers, you can use the Seam API in your app, and your users can authorize your app to control their devices using Seam.
For detailed information about the 4SUITES devices that Seam supports, see the following table and our 4SUITES Supported Devices page:
To learn more about other IoT device and system brands that Seam supports—such as Yale, Schlage, Google Nest, and many more—visit our integration page.
This guide shows you how to install a Seam SDK and then control your 4SUITES lock using the Seam API.
Another easy way to learn about what you can do with the Seam API is to explore the interactive Seam CLI, which you can access from directly within the Seam Console.
Step 1: Install a Seam SDK
Seam provides client libraries for many languages, including JavaScript, Python, Ruby, PHP, and others, as well as a Postman collection and an OpenAPI spec.
This guide uses a sandbox workspace. You can only connect virtual devices and systems in this type of workspace. If you want to connect a real 4SUITES lock, use a non-sandbox workspace and API key.
Step 2: Link your 4SUITES account with Seam
To control your 4SUITES lock using the Seam API, you must first authorize your Seam workspace to connect to your 4SUITES account. If your application needs to connect to your users' 4SUITES accounts, Seam provides fully-embedded, customizable client-side Connect Webviews to collect their authorization securely. These user-friendly pre-built authorization flows walk your users through the process of granting your Seam workspace permission to control their 4SUITES locks. The Connect Webview presents a flow that prompts your users to enter their credentials for their 4SUITES account.
In this guide, you create a Connect Webview object. Then, you display the graphical component of the created Connect Webview and enter a set of sample credentials to connect a sandbox 4SUITES account.
This guide shows you how to create a Connect Webview programmatically using the Seam API.
The Seam Console provides another easy way to connect devices to your Seam workspace.
Create a connect_webview object and then note the returned URL.
Code:
from seam import Seamseam =Seam()# Seam automatically uses your exported SEAM_API_KEY.connect_webview = seam.connect_webviews.create(accepted_providers=["four_suites"])assert connect_webview.login_successful isFalse# Use the returned Connect Webview URL to display# the Connect Webview authorization flow to your user.print(connect_webview.url)
import { Seam } from"seam";constseam=newSeam(); // Seam automatically uses your exported SEAM_API_KEY.constconnectWebview=awaitseam.connectWebviews.create({ accepted_providers: ['four_suites']});console.log(connectWebview.login_successful); // false// Use the returned Connect Webview URL to display// the Connect Webview authorization flow to your user.console.log(connectWebview.url);
require"seam"seam =Seam.new() # Seam automatically uses your exported SEAM_API_KEY.connect_webview = seam.connect_webviews.create( accepted_providers: ["four_suites"])puts connect_webview.login_successful # false# Use the returned Connect Webview URL to display# the Connect Webview authorization flow to your user.puts connect_webview.url
<?phprequire'vendor/autoload.php';$seam =newSeam\SeamClient(); // Seam automatically uses your exported SEAM_API_KEY.$connect_webview = $seam->connect_webviews->create( accepted_providers: ["four_suites"]);echo $connect_webview->login_successful ?'true':'false',"\n"; // false// Use the returned Connect Webview URL to display// the Connect Webview authorization flow to your user.echo $connect_webview->url;
usingSeam.Client;var seam =newSeamClient(apiToken: SEAM_API_KEY);var connectWebview =seam.ConnectWebviews.Create( acceptedProviders:new() {Seam.Api.ConnectWebviews.CreateRequest.AcceptedProvidersEnum.FourSuites});Console.WriteLine(connectWebview.LoginSuccessful); // False// Use the returned Connect Webview URL to display// the Connect Webview authorization flow to your user.Console.WriteLine(connectWebview.Url);
importjava.io.Console;importjava.util.*;importcom.fasterxml.jackson.annotation.*;importcom.fasterxml.jackson.databind.annotation.JsonDeserialize;importcom.seam.api.Seam;importcom.seam.api.core.ObjectMappers;importcom.seam.api.types.ConnectWebview;importcom.seam.api.types.Device;importcom.seam.api.types.Manufacturer;importcom.seam.api.types.ActionAttempt;importcom.seam.api.types.AccessCode;importcom.seam.api.resources.connectwebviews.requests.ConnectWebviewsCreateRequest;importcom.seam.api.resources.connectwebviews.requests.ConnectWebviewsGetRequest;importcom.seam.api.resources.devices.requests.DevicesListRequest;importcom.seam.api.resources.devices.requests.DevicesGetRequest;importcom.seam.api.resources.locks.requests.LocksUnlockDoorRequest;importcom.seam.api.resources.accesscodes.requests.AccessCodesCreateRequest;importcom.seam.api.resources.accesscodes.requests.AccessCodesListRequest;publicclassMain {publicstaticvoidmain(String[] args) {Seam seam =Seam.builder().apiKey(SEAM_API_KEY).build();ConnectWebview connectWebview =seam.connectWebviews().create(ConnectWebviewsCreateRequest.builder().acceptedProviders(List.of(AcceptedProvider.FOUR_SUITES)).build());System.out.println(connectWebview.getLoginSuccessful()); // false// Use the returned Connect Webview URL to display// the Connect Webview authorization flow to your user.System.out.println(connectWebview.getUrl()); }}
In a web browser, go to the URL that the Connect Webview object returned.
For application developers, you can redirect your user to this Connect Webview URL so that they can authorize your app to control their devices using Seam. We even provide a prebuilt Connect Account Button within our suite of Seam Components that help you build your device management flow.
Because you're using a sandbox workspace, you can connect Seam's test 4SUITES account. We provide virtual devices for each of the brands that we support. These sandbox devices and systems enable you to test your app with devices from multiple brands without the need to own all the corresponding physical devices.
Complete the Connect Webview authorization flow by entering the following 4SUITES sandbox account credentials:
Email: jane@example.com
Password: 1234
Confirm that authorization through the Connect Webview was successful by querying its status.
When you link a 4SUITES account with Seam, we create a device object to represent each 4SUITES lock in your account. You can then retrieve these 4SUITES devices using the List Devices and Get Device endpoints.
The Seam API exposes each device's properties, such as the door lock status, power status, capabilities, and so on.
Code:
# Retrieve all devices, filtered by manufacturer,# which is one of several filters that list() supports.all_four_suites_locks = seam.devices.list(manufacturer="four_suites")# Select the first device as an example.front_door = all_four_suites_locks[0]# Inspect specific properties.assert front_door.properties["online"]isTrue# Trueassert front_door.properties["locked"]isTrue# True# View the entire returned device object.pprint(front_door)
# Retrieve all devices, filtered by manufacturer, which is# one of several filters that the list endpoint supports.all_four_suites_locks=$(# Use GET or POST.curl-X'GET' \'https://connect.getseam.com/devices/list' \-H'accept: application/json' \-H"Authorization: Bearer ${SEAM_API_KEY}" \-H'Content-Type: application/json' \-d'{ "manufacturer": "four_suites" }')# Select the first device as an example.front_door=$(jq-r'.devices[0]'<<<${all_four_suites_locks})# Inspect specific properties.echo $(jq-r'"Online (true): " + (.properties.online | tostring)'<<<${front_door})echo $(jq-r'"Locked (true): " + (.properties.locked | tostring)'<<<${front_door})# View the entire returned device object.echo ${front_door}
// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.constallFourSuitesLocks=awaitseam.devices.list({manufacturer:"four_suites"});// Select the first device as an example.constfrontDoor= allFourSuitesLocks[0];// Inspect specific properties.console.log(frontDoor.properties.online); // trueconsole.log(frontDoor.properties.locked); // true// View the entire returned device object.console.log(frontDoor);
# Retrieve all devices, filtered by manufacturer,# which is one of several filters that list() supports.all_four_suites_locks = seam.devices.list(manufacturer: "four_suites")# Select the first device as an example.front_door = all_four_suites_locks[0]# Inspect specific properties.puts front_door.properties.online # trueputs front_door.properties.locked # true# View the entire returned device object.puts front_door.inspect
// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.$all_four_suites_locks = $seam->devices->list(manufacturer:"four_suites");// Select the first device as an example.$front_door = $all_four_suites_locks[0];// Inspect specific properties.echo $front_door->properties->online ?'true':'false',"\n"; // trueecho $front_door->properties->locked ?'true':'false',"\n"; // true// View the entire returned device object.echojson_encode($front_door, JSON_PRETTY_PRINT);
// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.var allFourSuitesLocks =seam.Devices.List( manufacturer:Seam.Api.Devices.ListRequest.ManufacturerEnum.FourSuites);// Select the first device as an example.Device frontDoor =allFourSuitesLocks[0];// Inspect specific properties.Console.WriteLine(frontDoor.Properties.Online); // trueConsole.WriteLine(frontDoor.Properties.Locked); // true// View the entire returned device object.Console.WriteLine(frontDoor);
// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.var allFourSuitesLocks =seam.devices().list(DevicesListRequest.builder().manufacturer(Manufacturer.FOURSUITES).build());// Select the first device as an example.Device frontDoor =allFourSuitesLocks.get(0);// Inspect specific properties.System.out.println(frontDoor.getProperties().getOnline()); // trueSystem.out.println(frontDoor.getProperties().getLocked()); // true// View the entire returned device object.System.out.println(frontDoor);
// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.allFourSuitesLocks, err := client.Devices.List( context.Background(), &api.DevicesListRequest{ Manufacturer: api.ManufacturerFourSuites.Ptr(), },)// Select the first device as an example.frontDoor := allFourSuitesLocks[0]if err !=nil {return err}// Inspect specific properties.fmt.Println(frontDoor.Properties.Online) // truefmt.Println(*frontDoor.Properties.Locked) // true// View the entire returned device object.fmt.Println(frontDoor)returnnil
Next, you can use the Seam API to control your lock.
Each device that you connect to Seam has a specific set of capabilities. These capabilities define the Seam API actions that you can use, such as remote unlock actions, programming access codes, and so on. Seam's intuitive and granular capability flags inform your application about what features and behaviors each device supports. Notice the capability flags within the code samples in this guide.
Try out the following actions on your 4SUITES lock:
Unlock your lock
To unlock a door, use the Unlock Door endpoint. Specify the device that you want to unlock by including the device_id in the request body. This endpoint returns an action attempt to track the progress of the unlock operation.