API Enhancement

Going through the API and the list of commands I am noticing that the layout for the capabilities is not very JSON friendly. Is there any initiative to change the layout so that strings and arrays are not mixed?
Also, is there any way to get the current status of a device with the API? Working on a little project and these two things would make life alot easier! Thanks in advance.

I've not had any issues with the JSON layout, but there are a lot of places I'd like it to be different.

As for getting a device status, just call the device directly (http://[hubitat]/apps/api/[maker_api]/devices/[Device ID]?access_token=[token])

Device status will be in the "attributes" object.

I am trying to parse the api call and JSON for java does not like the mixing of objects. if they were "more flat" and did not have strings and arrays together, it would make life simpler.
I see that now, completely overlooked it. Thanks!

1 Like

Ohhhhh, yeah Java can be a pain in terms of JSON slurping. I use nodejs for all my JSON stuff because JSON.parse() almost always works on pretty much anything I throw at it.

@patrick - Are there any plans to make the api return objects more uniform? Mixing strings, objects, and arrays makes parsing data very challenging.

There are no plans to change the formatting of this API app. That would cause more problems for all those that are using it today.

Is there a way to make a custom API that could redo the layout? @patrick

Sure. You could always build your own in groovy. Or are you asking about custom development?

1 Like

It's really not that hard to do it in Groovy yourself. Then you can define what to return, and how its' formatted.