How to get the Resin ID (not the UUID)


#1

Hi all, I wanted to know how can I get the Resin device ID (number) on the device because I have not seen any environment variables for it.
If that is not possible, how to get it with the API calls? I can read the UUID env var, but with it is not easy to get the normal ID (no matter if it is reading env vars or calling the API.
Thanks


#2

I am checking with the team. Why do you need the device ID, perhaps there is a different approach we can take to solve your problem?


#3

I need it because most of the API calls need the device ID. I use the initial information available on the device to then it to my own database, and then do operations with the API based on that. Because I can’t do the API calls with the UUID, first I have to get the device ID


#4

Hi,

You can use the device UUID to make API calls, for example:

curl "https://api.resin.io/v2/device?\$filter=uuid%20eq%20'328ae21ee894449b0a1ee4e4ece09b04'"
-H "Content-Type: application/json"
-H "Authorization: Bearer <auth_token>"

You will need to replace 328ae21ee894449b0a1ee4e4ece09b04 with your device UUID.


#5

Oh thank you very much! I didn’t know that you could also use the UUID instead.
Here on the APi docs https://docs.resin.io/runtime/data-api/ I could not find it, and I was wondering if it was because it is not possible or is just not documented.
Anyway, thanks for the quick help.


#6

Glad to help, we are improving our docs so this should be documented soon.


#7

Out of curiosity, regarding API calls… why are there two different IDs (device ID and UUID)? are there any recommendations of when to use which one?


#8

I think it’s a legacy issue, we are trying to move towards using the device UUID only so I would recommend you use that wherever possible.


#9

Good to know. Thanks again!