API Question - Smart Home & API / API - Rachio Community

API Question

post by Mikec on Nov 23, 2022

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 = 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.

post by Gene on Nov 23, 2022

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

post by Mikec on Nov 24, 2022

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