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.
#
Installationtip
Find the SmartThings Core SDK source on our GitHub repository.
#
AuthenticationYou 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:
- BearerTokenAuthenticator - This authenticator is instantiated with any valid bearer token. This is the authenticator to use with a PAT (Personal Access Token).
- RefreshTokenAuthenticator -- This authenticator is instantiated with a bearer token and a RefreshTokenStore that provides methods for retrieving and storing access and refresh tokens. When this authenticator is used, the API will automatically refresh expired access tokens, save the new tokens, and retry the original request.
- SequentialRefreshTokenAuthenticator
For more information on authenticating with the SmartThings Platform, visit Authorization and Permissions.
#
Import the Core SDK Into Your ApplicationImport the Core SDK into your JavaScript or TypeScript application:
NodeJS:
ES2015+:
#
Example UsageThe 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:
tip
For tutorials and more, visit the SmartThings Community.
#
EndpointsFor 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.