Balena API does not return correct Device status or update state

Unsure if this is the correct place to ask this, but I am rather confused by the response I am getting from the Balena REST API.

I am querying a Device by its resource ID (that I retrieved via the SDK) and can get 200 OK response.

https://api.balena-cloud.com/v5/device(3726613)

I get my 200 response and I can see a data structure that matches what is shown in the documentation (fields such as device_name, device_type, uuid as expected).

However when I look at the values of the following fields (after moving the Device to a new pinned release) whilst the Device is updating (seen in the Dashboard) there is no change to these fields:

"status": "Idle",
"provisioning_progress": null,
"provisioning_state": "",
"download_progress": null,

Is there something I might be doing wrong? Do these fields ever show correct data?

Any help is very much appreciated as I feel like I’m going mad

Hi,

I believe what you’re seeing in your API call are legacy values. It’s better to access these fields from the supervisor API endpoints, like:

curl -X POST --header "Content-Type:application/json" \
    --header "Authorization: Bearer <auth token>" \
    --data '{"uuid": <uuid>, "method": "GET"}' \
    "https://api.balena-cloud.com/supervisor/v1/device"

Details on the supervisor API can be found here: https://www.balena.io/docs/reference/supervisor/supervisor-api/.

Let us know how you make out.

John

Hi John,

Thanks for the response. I’ve given it ago as you suggested, whilst also manually triggering an update to a different release.

Whilst I did see an (expected) change on the update_pending field, none of the other fields changed before/during the update through the Dashboard.

{
“api_port”: REDACTED,
“ip_address”: REDACTED,
“os_version”: “balenaOS 2.48.0+rev1”,
“supervisor_version”: “10.8.0”,
“update_pending”: true,
“update_failed”: false,
“update_downloaded”: false,
“status”: “Idle”,
“download_progress”: null
}

Hi, can you describe in more detail what you are trying to achieve? Knowing more about your usecase would help.
For example, if you want to query for device update status, you could use https://www.balena.io/docs/reference/supervisor/supervisor-api/#get-v2applicationsstate

1 Like

Following some futher poking around in the Supervisor API documentation (https://www.balena.io/docs/reference/supervisor/supervisor-api/) I have found two other endpoints that seem to provide relevant information that is up to date.

The first providing me with a view of the services (although its only part of the picture).

The second giving me a detailed rundown of all the containers and images that are downloaded or being downloaded which is very useful.

I think between these I will be able to cobble together the information I am looking to extract, although its a shame that it doesn’t just work with the existing generic device APIs.