SmartThings

SmartThings

IoT

API for Samsung SmartThings Smart Home Hub products (ZigBee, Z-Wave, IP). The SmartThings platform has the largest coverage of competitive IoT devices on the market, including Samsung devices and appliances. It's easy to integrate existing products with our ecosystem, using developer features such as SmartThings Schema and open APIs.

Visit API

📚 Documentation & Examples

Everything you need to integrate with SmartThings

🚀 Quick Start Examples

SmartThings Javascript Examplejavascript
// SmartThings API Example
const response = await fetch('http://developer.smartthings.com/', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Introduction to SmartThings Public API

SmartThings is an IoT platform that provides various smart devices to users. These smart devices can be controlled via the SmartThings mobile app. SmartThings also provides a public API that allows developers to create their own custom applications and integrations with the SmartThings platform.

The SmartThings Public API documentation can be found at http://developer.smartthings.com/. This documentation provides various API endpoints for developers to interact with the SmartThings platform.

Example API Code in JavaScript

Let's take a look at some example code in JavaScript that can interact with the SmartThings Public API.

Getting an Access Token

Before we can interact with the SmartThings Public API, we need to get an access token. We can get an access token by sending a POST request to the following endpoint:

const axios = require('axios');

// Send a POST request with the client ID and client secret to get an access token
axios.post(
  'https://auth-global.api.smartthings.com/oauth/token', 
  {
    client_id: 'CLIENT_ID',
    client_secret: 'CLIENT_SECRET',
    grant_type: 'client_credentials',
    scope: 'app'
  }
)
.then(response => {
  const accessToken = response.data.access_token;
  console.log('Access Token:', accessToken);
})
.catch(error => {
  console.log('Error:', error);
});

Creating a Device

We can create a device on the SmartThings platform by sending a POST request to the following endpoint:

// Send a POST request with the device details to create a new device
axios.post(
  'https://api.smartthings.com/v1/devices',
  {
    label: 'My New Device',
    deviceTypeID: 'myDeviceType',
    deviceTypeName: 'My Device Type',
    components: [
      {
        id: 'main',
        capabilities: [
          {
            id: 'switch',
            version: 1
          }
        ]
      }
    ]
  },
  {
    headers: {
      Authorization: `Bearer ${accessToken}`
    }
  }
)
.then(response => {
  console.log('Device:', response.data);
})
.catch(error => {
  console.log('Error:', error);
});

Getting Device Status

We can get the status of a device by sending a GET request to the following endpoint:

// Send a GET request to get the device status
axios.get(
  'https://api.smartthings.com/v1/devices/DEVICE_ID/status',
  {
    headers: {
      Authorization: `Bearer ${accessToken}`
    }
  }
)
.then(response => {
  console.log('Device Status:', response.data);
})
.catch(error => {
  console.log('Error:', error);
});

Conclusion

This blog post covered the basics of the SmartThings Public API and provided some example code in JavaScript that can interact with the API. With the SmartThings Public API, developers can create custom applications and integrations that can enhance the user experience of the SmartThings platform.

📊 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

May 31Jun 2Jun 4Jun 6Jun 8Jun 10Jun 12Jun 14Jun 16Jun 18Jun 20Jun 22Jun 24Jun 26Jun 2904008001440Minutes
Online
Offline

Related APIs in IoT