Displaying HA data on a website - API access

Hi. I am trying to pull some HA sensor data to display on a website. I am having difficulty accessing the HA API.

Can I do this using my Nabu Casa url? https://xxxxxxxxxxx.ui.nabu.casa/api does not work. The response is ‘unaurthorized’… how do I gain authorization? I have a long life token.

I tried https://xxxxxxxxxxx.ui.nabu.casa/api/states/my_sensor?Authorization=Bearer_(long_life_token) which does not work either…

I have added api: to my config.yaml.

Any thoughts?

You need to put the token in a request header, not as a parameter in the URL.

Thanks…

So the Nabu Casa url should work, whne using Word press and WPGetAPI?

  1. Base URL is https://xxxxxxxxxxxxxxxxxx.ui.nabu.casa/api
  2. Endpoint is /states/sensor.my_sensor
  3. Headers - Authorization: Bearer (long life token)
    Content-Type: Application/json

When I use the ‘test’ button in WPGet, it returns unauthorized

Hummm… now getting ‘invalid header token’

Any ideas?

Sorted :slight_smile:

I had included a ‘:’ after Bearer - removed that and all good :slight_smile:

1 Like