Getting Started with the SmartBuildings Public API

Initial setup

To get started with the SmartBuildings API, you will need an active SmartBuildings subscription and a client ID and secret. These credentials are distinct from your login credentials on the SmartBuildings portal. To get set up with a client ID and secret, please contact [email protected] from the email address associated with your SmartBuildings account.

Get a jwt token

Using the client_id and client_secret for a specific SmartBuildings account integration, create a jwt token that will be used to make all other API calls when acting on behalf of that account.

curl --request POST \
  --header "Content-type: application/json" \
  --url "https://api.sb.ecobee.com/token" \
  --data '{ "audience": "https://api.sb.ecobee.com", "grant_type": "client_credentials", "scopes": "read:thermostat read:thermostats", "client_id": "<insert client_id>", "client_secret": "<insert client_secret>" }'
const axios = require('axios');

const clientId = '<insert client_id>';
const clientSecret = '<insert client_secret>';

const data = {
  audience: 'https://api.sb.ecobee.com',
  grant_type: 'client_credentials',
  scope: 'read:thermostat read:thermostats',
  client_id: clientId,
  client_secret: clientSecret
};

axios
  .post('https://api.sb.ecobee.com/token', data)
  .then(res => {
    console.log(res.data.access_token);
  })
  .catch(err => {
    console.log(err);
  });

Get a list of thermostat IDs

Using the jwt token retrieved via the /token route, act on behalf of a SmartBuildings account to retrieve the list of thermostat ids associated with their account.

curl --request GET \
  --header "Authorization: Bearer <insert jwt token>" \
  --url "https://api.sb.ecobee.com/api/v1/thermostatIds"
const axios = require('axios');

const accessToken = '<insert access_token>';

axios({
  url: 'https://api.sb.ecobee.com/api/v1/thermostatIds',
  method: 'GET',
  headers: {
    Authorization: `Bearer ${accessToken}`
  }
})
  .then(res => {
    console.log(res.data);
  })
  .catch(err => {
    console.log(err);
  });

What’s Next

Read about the OpenAPI 3 Specification for the SmartBuildings API...

Did this page help you?