Maker API - JSON Response Question

I've been playing with Maker API to pull some attribute values for a dashboard I'm working with and I've noticed that things like a hub reboot / update or adding / removing devices significantly changes the JSON response to the point that I'm constantly having to make changes to keep correct things. At first, I thought it was because I was changing the selected devices being used with Maker API, but after finally deciding to select them all, I was still noticing the array of the response changing.

Being new to this, I'm probably going about this the wrong way, so I'm wondering what the correct way to do this would be. With every other API I work with, the JSON response is very structured and consistent, so I can just point to a specific point in the array and it just works. I feel like I'm going to need to do something differently here, but I don't know what.

Can you be more specific about what you mean with "changing"?

As a guess: if you mean the order of the devices in the device list (an array of objects), that order is completely arbitrary. As such, using an index into that array is generally not a good idea. (This advice isn't particular to Maker API but rather is how I would treat JSON data in general, unless the API you're using makes such a guarantee; Maker API does not, as the order is not inherently meaningful.)

If you're looking for a particular device, you need to find it by an identifier related to the specific object you're looking for. A good choice is the device ID, which is part of this data, as that is assigned by the hub and is stable and unique for every device; however, the name, label, or whatever data could also be used to meet your needs would work (as long as you know that they aren't any of these things, though are mostly under your control). Whatever the solution is for you, the idea is you need something besides the index in the array. Someone can probably give more hints if you're not sure if you share more information about exactly what you're doing on the other side of things.

Yeah, the order of the devices is what I'm referring to. In the screenshot below, I would use 0.attributes.switch to obtain the state of the switch. This is how I've always done it because it's always worked for me with every other API I've interacted.

So, how would I obtain that same value in a way that would work regardless of where in the array that device might end up?

This is going to depend on

What tool or programming/scripting language are you using there?

This is what I'm using. It's worked perfectly with the Aeris Weather API using dot notation as shown in my example above. I've tried it with the "all devices" URL from Maker API, and it works fine for most devices, but the order does change every now and then. I've also tried it with a specific device, but I've even seen the attributes move around , which, of course, also breaks things.

I am not familiar with that application, but a quick look at the docs didn't show anything exactly like what I was thinking (though this is pretty common JSON parsing libraries, and I'd really like to think I'm just missing something here; I didn't dig in much). However, two other approaches might work: I see they have dynamic-list for mapping raw data to other formats, which might be promising if you play around with it a bit; or you could just fetch information about each device individually by ID. It sounds like you tried that already, but I'm not quite sure where the breakdown was there; this should really be doable since you just get a single object, not a list.

I'd still like to think there should be a way to look for an object by some data in its value, not just its position in the outer array, so you might want to poke around their docs for more examples to see what I'm missing. If they have a forum or other user-to-user support channels, asking there would probably get you better help from users more familiar with it -- unless anyone here happens to be.