Getting Started with the SmartBuildings Public API
Here are a couple examples just to get you started.
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/thermostaIds"
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);
});
Updated almost 5 years ago
What’s Next
Read about the OpenAPI 3 Specification for the SmartBuildings API...