Setting up an API to create a custom GUI

I hope this still falls under the “Installation” category. If not, let me know, willing to repost it on “Development”.

Anyway: I’m a complete noob to HA & I’ve been really struggling with getting the API to work, as nothing that I found in the documentation seemed to work for me. (stuck at 401: unauthorized).

I used to have my configuration.yaml set up with http: api_password:, but then apparently this has been deprecated. Then I tried setting it up with auth_providers, but now HA keeps going into safe mode and I really haven’t got the slightest clue of what I’m doing.

Can anybody please point me to a step by step to-do-list (or tutorial) for setting up the API? I find the documentation very confusing… and I may just be too much of a noob to pull this off.

Thanks in advance!

This is how i use the api in a python script:

import yaml
import requests

config_file = '/home/homeassi/.homeassistant/variables.yaml'
url = 'http://localhost:8123/api/states/variable.'

headers = {
    'Authorization': 'Bearer 123...abc',
    'content-type': 'application/json'
}

You can create the Bearer token in your user profile.
Auswahl_396

I kind of understand where everything is coming from except this line. Is this the folder of your own application or is this somewhere inside the HA folders?

Thanks in advance!

Forget this line, just a part of the script.
Has nothing to do with the API.

Cool! I finally got my API up-and-running thanks to your help!

Thanks a lot! :grin: