Getting devices and events via the SmartThings API

Hi,

I’m not a full developer, but I`m working with home automation and hence trying to accomplish the following using the SmartThings API:

  1. List devices (initially a dryer and a washer)
  2. List device events

Later on I might try other things, but this is my initial plan in order to see how the API works and what can be done.

Based on the following guide:
https://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/authorization.html

I have performed the following (using PowerShell):

  1. Created a SmartApp with OAuth enabled. The app code is not modified beyond the default template.
  2. Request an authorization code.
  3. Use the code to request an access token.
  4. Get the endpoint URI for the SmartApp.

I get 4 URLs, one example:
https://graph-eu01-euwest1.api.smartthings.com:443/api/smartapps/installations/c7344c7a-313c-4296-8eb4-fe8ca8223f20

When trying to send a GET request to the URL`s, I get an “The remote server returned an error: (403) Forbidden.”.

If I append /devices to the URLs, I get an “The remote server returned an error: (404) Not Found.” error.

What do I need to do to proceed to get a list of devices and their events?

Using the current API, you can’t, without first writing an entire SmartApp that allows the user to Authorize which devices you are allowed to access, and then defines custom REST-API endpoint mappings to perform specific functions on those Devices, such as fetching their Events and responding in JSON.

Please read this section of the Docs much more carefully:

https://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/smartapp.html#the-smartapp

You may also want to consider the “new” Samsung SmartThings Cloud API, though it is only in Beta, docs are incomplete, and subject to change. And you will find less peer-support for it.

https://smartthings.developer.samsung.com/develop/api-ref/st-api.html

Ah - thanks a lot. I`ll look into the new beta API instead.

1 Like

I just started working on a project using this API, but the documentation seems to have a problem.

The page just shows “Loading” when I try to open it.