Feature Request: Maker API All Devices JSON

The full details JSON returned by using the URL http://[hub IP]/apps/api/[MakerAppID]/devices/all?access_token=[access token] returns some odd JSON for attributes unlike the individual device access. Here's an example for a generic outlet from the all devices JSON:

	"attributes": {
		"power": "2",
		"dataType": "ENUM",
		"values": ["on","off"],
		"switch": "off"
	}

Here's what it looks like if accessed individually:

	"attributes": {
	[	
		{
			"name": "power",
			"dataType": "NUMBER",
			"currentValue": "2"
		},
		{
			"name": "switch",
			"dataType": "ENUM",
			"values": ["on","off"],
			"currentValue": "off"
		}
		]
	}

You can use the 'all devices' to get all the IDs and then call each device individually, but it'd be nice if the 'all devices' call returned the data with the same schema as the individual device calls to minimize the round trips.

I'll look into this...

Which individual device access method are you talking about?

http://[IP]/apps/api/[appid]/devices/[deviceid]/capabilities?access_token=[accesstoken] and
http://[IP]/apps/api/[appid]/devices/[deviceid]?access_token=[accesstoken] both seem to return attributes with the same (correct) schema, although capability attributes have datatype of null for the latter URL, and capabilities are missing their commands for both URLs. Looks like they are all grouped together in the device's command list instead which means there are dupes.

It would be a problem changing this, given that there could be code out there depending on the current format returned by /devices/all. So, what we would need is a new endpoint that would build its json the same way as /devices/[deviceid].

Version it? V2?

Perhaps. I had the same thought. Will investigate further...

Have you tried /devices ?

I don't think that is documented well. There are two endpoints that use the same method of building the json:

/devices

and

/devices/[device-id]

When the /[device=id] is omitted, it returns all of the selected devices in the same format.

Yeah, if that's the GetAllDevices link on the Maker API app page, that just gets a minimal set of metadata for all the devices. That's the one I use to first get the list before getting the full info from the device-specific URL that has the good attributes schema.

I understand that you were talking about /devices/all. What I'm asking is if /devices without a specified device gets you all of the information you need in the format you want? No point in changing /devices/all if you can get what you need the other way.

That is the URL I am talking about. From the Maker API app config, there is a link 'Get All Devices' with URL http://[HubIP]/apps/api/[MakerApiID]/devices?access_token=[AccessToken] that doesn't have 'all' in it.

This api method only returns a bare minimum set of metadata for all the devices with no attributes, capabilities or anything.

I am also curious, is the mechanism the maker API uses to expose a rest endpoint documented? I assume this is the same mechanism as the SharpTools app?

Edit: Never mind, I found the open-dash/housepanel implementations that provide a good example of this.

Yes, sorry, you're right about that. I have a fix to allow you to get either that bare minimum or the full list with the same format as the individual device. This will be in the next release.

To get full info will be to use * for [device-id].

2 Likes

Awesome, thanks!