Seam provides a unified API to connect and control IoT devices, such as smart locks, thermostats, cameras, and sensors. This guide walks you through issuing your first device API call.
Step 1 — Connect Devices
To get started with Seam, first connect a set of devices.
When prompted, type the following sample (sandbox) credentials:
Email:jane@example.com
Password:1234
Click Submit.
When prompted for a two-factor authentication (2FA) method, select Email.
In the Two Factor Code field, type 123456 and then click Submit and Continue.
Once authorized, the devices associated with this test account appear in your workspace.
Step 2 — Get an API Key and SDK
To control the devices that you connected in Step 1, you must create an API key and install the Seam SDK in the programming language of your choice.
Create an API Key
In left navigation pane of the Seam Console, click API Keys.
In the upper-right corner of the API Keys page, click + Add API Key.
In the Add API Key dialog, type a name for your new API key and then click Create API Key.
Copy the newly-created API key and store it for future use.
Install the Seam SDK
Install one of the Seam SDKs in the programming language of your choice.
Seam provides client libraries for many languages, such as JavaScript, Python, Ruby, PHP, and others, as well as a Postman collection and OpenAPI spec.
The Seam SDK that you have installed automatically uses this API key once you have exported it.
Next, use the following code to retrieve one of the devices that you connected in Step 1, inspect the supported capabilities of the device, and use the Seam API to unlock the door:
Code:
from seam import Seamseam =Seam()# Seam automatically uses your exported SEAM_API_KEY.# Retrieve all devices, filtered by manufacturer,# which is one of several filters that list() supports.all_august_locks = seam.devices.list(manufacturer="august")# Select the first device as an example.front_door = all_august_locks[0]# Confirm that the device can remotely unlock.# You're using a capability flag here!if front_door.can_remotely_unlock:# Perform the unlock operation# and return an action attempt. action_attempt=seam.locks.unlock_door(device_id=front_door.device_id)
# Retrieve all devices, filtered by manufacturer, which is# one of several filters that the list endpoint supports.all_august_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": "august" }')# Select the first device as an example.front_door=$(jq-r'.devices[0]'<<<${all_august_locks})# Confirm that the device can remotely unlock.# You're using a capability flag here!if$(jq-r'.can_remotely_lock'<<<${front_door}); then \# Perform the unlock operation# and return an action attempt.curl-X'POST' \'https://connect.getseam.com/locks/unlock_door' \-H'accept: application/json' \-H"Authorization: Bearer ${SEAM_API_KEY}" \-H'Content-Type: application/json' \-d"{ \"device_id\": \"$(jq-r '.device_id' <<<${front_door})\" }";fi
import { Seam } from"seam";constseam=newSeam(); // Seam automatically uses your exported SEAM_API_KEY.// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.constallAugustLocks=awaitseam.devices.list({manufacturer:"august"});// Select the first device as an example.constfrontDoor= allAugustLocks[0];// Confirm that the device can remotely unlock.// You're using a capability flag here!if (frontDoor.can_remotely_unlock) {// Perform the unlock operation// and return an action attempt.constactionAttempt=awaitseam.locks.unlockDoor({ device_id:frontDoor.device_id });};
require"seam"seam =Seam.new() # Seam automatically uses your exported SEAM_API_KEY.# Retrieve all devices, filtered by manufacturer,# which is one of several filters that list() supports.all_august_locks = seam.devices.list(manufacturer: "august")# Select the first device as an example.front_door = all_august_locks[0]# Confirm that the device can remotely unlock.# You're using a capability flag here!if (front_door.can_remotely_unlock)# Perform the unlock operation# and return an action attempt. action_attempt = seam.locks.unlock_door(device_id: front_door.device_id)end
<?phprequire'vendor/autoload.php';$seam =newSeam\SeamClient(); // Seam automatically uses your exported SEAM_API_KEY.// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.$all_august_locks = $seam->devices->list(manufacturer:"august");// Select the first device as an example.$front_door = $all_august_locks[0];// Confirm that the device can remotely unlock.// You're using a capability flag here!if ($front_door->can_remotely_unlock) {// Perform the unlock operation// and return an action attempt. $action_attempt = $seam->locks->unlock_door(device_id: $front_door->device_id);}
usingSeam.Client;var seam =newSeamClient(apiToken: SEAM_API_KEY);// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.var allAugustLocks =seam.Devices.List( manufacturer:Seam.Api.Devices.ListRequest.ManufacturerEnum.August);// Select the first device as an example.Device frontDoor =allAugustLocks[0];// Confirm that the device can remotely unlock.// You're using a capability flag here!if (frontDoor.CanRemotelyUnlock==true) { // Perform the unlock operation // and return an action attempt.ActionAttempt actionAttempt =seam.Locks.UnlockDoor(deviceId:frontDoor.DeviceId);}
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.Device;importcom.seam.api.types.Manufacturer;importcom.seam.api.types.ActionAttempt;importcom.seam.api.resources.devices.requests.DevicesListRequest;importcom.seam.api.resources.locks.requests.LocksUnlockDoorRequest;publicclassMain {publicstaticvoidmain(String[] args) {Seam seam =Seam.builder().apiKey(SEAM_API_KEY).build();// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.var allAugustLocks =seam.devices().list(DevicesListRequest.builder().manufacturer(Manufacturer.AUGUST).build());// Select the first device as an example.Device frontDoor =allAugustLocks.get(0);// Confirm that the device can remotely unlock.// You're using a capability flag here!if (frontDoor.getCanRemotelyUnlock()) {// Perform the unlock operation// and return an action attempt.ActionAttempt actionAttempt =seam.locks().unlockDoor(LocksUnlockDoorRequest.builder().deviceId(frontDoor.getDeviceId()).build()); } }}
packagemainimport ("context""fmt""os" api "github.com/seamapi/go" seam "github.com/seamapi/go/client")funcmain() {if err :=run(); err !=nil { _, _ = fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) }}funcrun() error { client := seam.NewClient( seam.WithApiKey(SEAM_API_KEY), )// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports. allAugustLocks, err := client.Devices.List( context.Background(), &api.DevicesListRequest{ Manufacturer: api.ManufacturerAugust.Ptr(), }, )// Select the first device as an example. frontDoor := allAugustLocks[0]if err !=nil {return err }// Confirm that the device can remotely unlock.// You're using a capability flag here!if*frontDoor.CanRemotelyUnlock {// Perform the unlock operation. actionAttempt, err := client.Locks.UnlockDoor( context.Background(),&api.LocksUnlockDoorRequest{ DeviceId: frontDoor.DeviceId, }, )if err !=nil {return err } }returnnil}
Now that you have completed the Seam API Quick Start, you are well on your way to writing code that can actually control the physical world! 😎
Here are some ideas of what you can do next.
Connect a Real Device
If you have a real device, you can try to control it using the steps in this Quick Start. Note that you must first create a production workspace because sandbox workspaces only enable you to connect test accounts and devices. For more information, see Workspaces.
Connect Users' Devices
If you are creating an application (app) to control your users' devices, see Connect Webviews. Seam Connect Webviews are fully-embedded client-side components that you add to your app if you want to enable your users to import their own devices using your app. Your users interact with your embedded Connect Webviews to link their IoT device accounts to Seam through your app. That is, Connect Webviews walk your users through the process of logging in to their device accounts. Seam handles all the authentication steps, and—once your user has completed the authorization through your app—you can access and control their devices using the Seam API.
Learn about Devices and Capabilities
Seam supports many device categories. Each device can be broken down into device capabilities. A capability indicates what the device can do, what properties it has, and what events it emits. To learn more about specific capabilities, such as access codes or thermostats, see the following guides: