API Question

I am attempting to do a simple query in a Python app to determine if any
of my zones are active. Not concerned which on but just need to know if
any are active. I am not having any luck connecting. I am a bit new
using API access so could use some guidance.

What I have attempted so far return this error - {“errors”:[{“message”:“The client is not authorized.”
The Person Info appears to return ok but I receive the error in response to the GET request

Here is the code I am using

API_KEY = <API key provided by my account settings>
r = Rachio(API_KEY)
resp, content = r.person.info()
# use Device ID from Person Info
url = "https://api.rach.io/1/public/device/"+content["id"]+"/current_schedule"
headers = {"accept": "application/json"}
response = requests.get(url, headers=headers)

I have also attempted to execute the GET request directly using the API
key provided under my account settings (not using device id provided by
person info). Get the same error.

url = "https://api.rach.io/1/public/device/API_KEY/current_schedule"
headers = {"accept: application/json"}
response = requests.get(url, headers=headers)|

Any help you can provide would be appreciated.

API is not used in the URL, instead you need to pass it via "Authorization:Bearer " header

I resolved this. Turns out I was accesing the wrong element in the returned data so not getting correct device id.

1 Like