API to look up the Model # for a given device

Is there an API that would return the model# when looking up a given device ID? Also, let's say you have a product based on the Boron chip and within this product you have two different "sub products". They have the same functions but when called return slightly different JSON formatted data. I'm building a front end portal and was wondering how to best handle a situation like this. I was thinking of manually setting a static variable within the firmware but wasn't sure if there is a better way of handling it.


The Get device information API endpoint will return a "platform_id" key, you can see here what each number stands for.

As for the "sub-product" variation, I would need more details into what the variants entail to give more recommendations, but you could likewise check for the platform ID in Device OS and use this to format your JSON accordingly.

Hope this helps.

1 Like

@morduno-particle as far as the "sub-product" I have certain devices that have a battery installed and certain that do not. So when I call a particle variable some will return the extra values about the battery status. I'm looking for a clean way to differentiate between these devices. In the future I may add additional data that newer devices in a product will return compared to the "legacy" ones.

To be clear, you're interested in determining your model number, not the Particle SKU, correct? There are a bunch of common ways to handle your use case:

If the keys in the JSON are different, you could just determine the model based on what keys are in the data. For example if there's a "soc" key with the state-of-charge, it has a battery.

You could add a model number to the JSON data. As long as you're not right up near the 1024 byte limit, the added bytes for this are generally not an issue.

You could add feature flags, a bitfield of the features of the device that sent the data instead of a single number.

You could store the model data on the back-end in your database. It's recommended that you use the Device ID as the key. This is the most data-efficient, and presumably you know what features were in the device when you assembled it. Since the event always has an associated Device ID, this works with both webhooks and SSE. This is the recommended way.

You could store the meta data, such as model and features, in the device notes field for your device. It's available to your front-end by getting the device info from the Particle cloud API. If you store the meta data in JSON, you can use DeviceNotesHelperRK to also read the data on-device, which is handy if you have cloud-configurable per-device features.

You could group your devices by model using the device groups feature. It's available to your front-end by getting the device info from the Particle cloud API. If the device needs to know what groups it's in, you can use DeviceGroupsHelperRK.

In JSON all fields are optional, so how about you let the devices that have battery send the related fields and the ones who don't don't send/populate them?
Then in your backend, you receive this info and can sort them out.

I would have them return the same data, but with the irrelevant fields ommited, perhaps.

@rickkas7 Yes, what I had in mind was the particle SKU. I did find find this tool which should work for now for me but was curious if there is a way to find this out on a per device API basis.

Thanks, the grouping will do for me!

Thanks @gusgonnet I have been just determining the device "sub-product" based on what has been JSON returns but wasn't sure if there is a cleaner way of doing this.

The Particle SKU is derived from the serial number prefix. Any serial number beginning with P has a 3-digit number after that which specifies the SKU. The docs uses a huge JSON file with this information, but it's hard to consume and since you have a finite number of SKUs, you can easily figure it out from the devices you have.

1 Like