# Hub status from API

**URL:** <https://community.tempest.earth/t/hub-status-from-api/6472>\
**Category:** Developers\
**Tags:** hub, rest\_api, websocket\
**Created:** [June 1, 2020, 7:14pm UTC](https://community.tempest.earth/t/hub-status-from-api/6472 "2020-06-01T19:14:13Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/peter/32/1365_2.png) [@peter](https://community.tempest.earth/u/peter)\
**Post date:** [June 1, 2020, 7:14pm UTC](https://community.tempest.earth/t/hub-status-from-api/6472/1 "2020-06-01T19:14:13Z")

</div>

I think I know the answer, but does anyone know if there is a way of telling whether a hub is online or not using the REST API? There seems to be a websocket endpoint for this, but in my testing I was unable to get it to trigger. It also seems that it doesn’t confirm what the state is upon first connection.

---

<div class="post-metadata">

**Author:** ![peter](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/peter/32/1365_2.png) [@peter](https://community.tempest.earth/u/peter)\
**Post date:** [June 1, 2020, 9:55pm UTC](https://community.tempest.earth/t/hub-status-from-api/6472/2 "2020-06-01T21:55:48Z")

</div>

I think (I’m guessing here) the answer to my own question lies in the fact that these details are not available to unauthorized users of the API (i.e. they can only be accessed by the station owner). In which case the Oauth2 flow is required.

> [@Cannot use websockets with Oauth2 token](https://community.tempest.earth/t/cannot-use-websockets-with-oauth2-token/5507):
>
> I used the Authorize button on the API testing interface to get a private token/key. It works fine using the REST API. However it does not work with websockets. I tried both endpoints ws and wss. I can use the demo key and all works but not the private key. Should this work or is there another way to get a private key?

@dsj sorry to badger when you are busy with Tempest, but can you comment on what progress has been made with this? Is it possible to implement Oauth2 authorization in a third party application yet?

---

<div class="post-metadata">

**Author:** ![GaryFunk](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/garyfunk/32/5729_2.png) [@GaryFunk](https://community.tempest.earth/u/GaryFunk)\
**Post date:** [June 2, 2020, 4:27am UTC](https://community.tempest.earth/t/hub-status-from-api/6472/3 "2020-06-02T04:27:24Z")

</div>

The answer is No. If you recall, there was a discussion months ago about the amount of time that the servers would indicate that the station was offline from the last data received.

This may help.

> [@Hub without power for several minutes status is still "online"](https://community.tempest.earth/t/hub-without-power-for-several-minutes-status-is-still-online/4992):
>
> After unplugging the Hub, the app showed its status as “online” even more then 5 min after unplugging. Even no push alert was send.

---

<div class="post-metadata">

**Author:** ![GaryFunk](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/garyfunk/32/5729_2.png) [@GaryFunk](https://community.tempest.earth/u/GaryFunk)\
**Post date:** [June 2, 2020, 4:37am UTC](https://community.tempest.earth/t/hub-status-from-api/6472/4 "2020-06-02T04:37:06Z")

</div>

I can’t remember if I took medicine at 2pm but I remembered this conversation.

---

<div class="post-metadata">

**Author:** ![peter](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/peter/32/1365_2.png) [@peter](https://community.tempest.earth/u/peter)\
**Post date:** [June 2, 2020, 8:11am UTC](https://community.tempest.earth/t/hub-status-from-api/6472/5 "2020-06-02T08:11:20Z")

</div>

Thanks for sharing this, Gary. That discussion happened when I was away down South so it must have slipped under my radar!

---

<div class="post-metadata">

**Author:** ![GaryFunk](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/garyfunk/32/5729_2.png) [@GaryFunk](https://community.tempest.earth/u/GaryFunk)\
**Post date:** [June 2, 2020, 8:26am UTC](https://community.tempest.earth/t/hub-status-from-api/6472/6 "2020-06-02T08:26:53Z")

</div>

I thought it was mid 2019 but at least I remembered it. I don’t know if David had the change put in place. If I can help in any way please feel free to ask.

---

<div class="post-metadata">

**Author:** ![dsj](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/dsj/32/3_2.png) [@dsj](https://community.tempest.earth/u/dsj)\
**Post date:** [June 2, 2020, 8:04pm UTC](https://community.tempest.earth/t/hub-status-from-api/6472/7 "2020-06-02T20:04:11Z")

</div>

> [@peter](#):
>
> I think I know the answer, but does anyone know if there is a way of telling whether a hub is online or not using the REST API?

There is not, but there should be. We will add the station and device status (online/offline) to the existing “/stations” endpoint in an upcoming API build. That should happen in the next week or two.

---

<div class="post-metadata">

**Author:** ![peter](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/peter/32/1365_2.png) [@peter](https://community.tempest.earth/u/peter)\
**Post date:** [June 3, 2020, 7:53am UTC](https://community.tempest.earth/t/hub-status-from-api/6472/8 "2020-06-03T07:53:16Z")

</div>

Great! That’s good to know 🙂 . Is there any chance you could also add “last seen” times for the station and the devices? That way we can choose a custom time interval after which a station/device is deemed offline

---

<div class="post-metadata">

**Author:** ![GaryFunk](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/garyfunk/32/5729_2.png) [@GaryFunk](https://community.tempest.earth/u/GaryFunk)\
**Post date:** [June 3, 2020, 8:06am UTC](https://community.tempest.earth/t/hub-status-from-api/6472/9 "2020-06-03T08:06:04Z")

</div>

Peter, those times are index 0 of each observation and status.

---

<div class="post-metadata">

**Author:** ![peter](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/peter/32/1365_2.png) [@peter](https://community.tempest.earth/u/peter)\
**Post date:** [June 3, 2020, 8:18am UTC](https://community.tempest.earth/t/hub-status-from-api/6472/10 "2020-06-03T08:18:20Z")

</div>

Doh - of course that’s true for the observations! I am not thinking straight yet this morning. I’m not sure about the hub status though (from the viewpoint of the Websocket/API rather than UDP). There isn’t a hub status endpoint, so having a “last seen” time and status would be useful in the stations/ end point.

---

<div class="post-metadata">

**Author:** ![GaryFunk](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/garyfunk/32/5729_2.png) [@GaryFunk](https://community.tempest.earth/u/GaryFunk)\
**Post date:** [June 3, 2020, 8:44am UTC](https://community.tempest.earth/t/hub-status-from-api/6472/11 "2020-06-03T08:44:48Z")

</div>

The Hub is a device so that time is in the status packet.

---

<div class="post-metadata">

**Author:** ![peter](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/peter/32/1365_2.png) [@peter](https://community.tempest.earth/u/peter)\
**Post date:** [June 3, 2020, 9:31am UTC](https://community.tempest.earth/t/hub-status-from-api/6472/12 "2020-06-03T09:31:30Z")

</div>

Sorry Gary, but I must be missing something. If you use the device API endpoint with a hub device id ([https://swd.weatherflow.com/swd/rest/observations/?device\_id=1109&api\_key=20c70eae-e62f-4d3b-b3a4-8586e90f3ac8](https://swd.weatherflow.com/swd/rest/observations/?device_id=1109&api_key=20c70eae-e62f-4d3b-b3a4-8586e90f3ac8)) you don’t get anything useful:

`{"status":{"status_code":0,"status_message":"SUCCESS"},"type":null,"source":"cache","obs":null}`

Also if you start listening on the websocket with a hub device id nothing is sent. Am I missing something obvious?

---

<div class="post-metadata">

**Author:** ![dsj](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tempest.earth/dsj/32/3_2.png) [@dsj](https://community.tempest.earth/u/dsj)\
**Post date:** [June 3, 2020, 5:40pm UTC](https://community.tempest.earth/t/hub-status-from-api/6472/13 "2020-06-03T17:40:55Z")

</div>

We will be adding a diagnostic service to the API soon that will give you the Hub’s “last seen” along with lots of other info. Coming soon!

And for what it’s worth, we use the latest observation time (from the sensor devices) to determine whether a station is online or offline. That’s because a station with a working hub but no working sensor devices is, for all practical purposes, offline.
