Skip to main content

SmartThings Core SDK

The SmartThings Core SDK is a wrapper designed to simplify the use of the SmartThings API when the API is called from JavaScript or TypeScript applications. With the Core SDK, you can easily integrate SmartThings APIs into your JavaScript and TypeScript applications.

important

The Core SDK is in early development. Changes may be made that are not backwards compatible.

Installation#

tip

Find the SmartThings Core SDK source on our GitHub repository.

npm install @smartthings/core-sdk

Authentication#

You must authenticate with the SmartThings Platform when interacting with SmartThings APIs.

The Core SDK supports multiple ways of authenticating with the SmartThings Platform. Available authenticators include:

For more information on authenticating with the SmartThings Platform, visit Authorization and Permissions.

Import the Core SDK Into Your Application#

Import the Core SDK into your JavaScript or TypeScript application:

  • NodeJS:

    const {SmartThingsClient} = require('@smartthings/core-sdk')
  • ES2015+:

    import {SmartThingsClient} from '@smartthings/core-sdk'

Example Usage#

The sample below demonstrates importing the Core SDK and retrieving a list of locations for a given user.

Substitute {YOUR-PAT-TOKEN} with your Personal Access Token (that has a scope of at least r:locations) in the following code:

const {SmartThingsClient, BearerTokenAuthenticator} = require('@smartthings/core-sdk')
const client = new SmartThingsClient(new BearerTokenAuthenticator('{YOUR-PAT-TOKEN}'))
client.locations.list().then(locations => {
console.log(`Found ${locations.length} locations`)
})
tip

For tutorials and more, visit the SmartThings Community.

Endpoints#

For a list of API endpoints, refer to the API documentation. To see these API endpoints utilized in code, visit the Core SDK README "Endpoints" section.