# Getting the Device ID (for API)

**URL:** <https://community.info-beamer.com/t/getting-the-device-id-for-api/352>\
**Category:** Help\
**Created:** [February 20, 2019, 3:33pm UTC](https://community.info-beamer.com/t/getting-the-device-id-for-api/352 "2019-02-20T15:33:46Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![lbwa](https://community.info-beamer.com/letter_avatar_proxy/v3/letter/l/4491bb/32.png) [@lbwa](https://community.info-beamer.com/u/lbwa)\
**Post date:** [February 20, 2019, 3:33pm UTC](https://community.info-beamer.com/t/getting-the-device-id-for-api/352/1 "2019-02-20T15:33:46Z")

</div>

When adding a device using the API we need the device ID, but all we can get is the Install Code (Hex) or letting the device add automatically to our account and the use the “Screen Info” package that shows the serial number.  
How do we show the user the “Device ID” to input to the API?

---

<div class="post-metadata">

**Author:** ![infobeamer-fw](https://community.info-beamer.com/user_avatar/community.info-beamer.com/infobeamer-fw/32/3_2.png) [@infobeamer-fw](https://community.info-beamer.com/u/infobeamer-fw)\
**Post date:** [February 20, 2019, 4:03pm UTC](https://community.info-beamer.com/t/getting-the-device-id-for-api/352/2 "2019-02-20T16:03:02Z")

</div>

I’m not entirely sure I understand: When you add a device programmatically through the API, you don’t need a device id. That’s because a device that isn’t yet part of any account doesn’t have one. A device id is only assigned _after_ a device is added. This is also reflected in how the [device/create](https://info-beamer.com/doc/api#createanewdevice) call works: You provide the 8 digit PIN shown on the screen and if that’s correct, the device is bound to your account and only then assigned a device id.

Let me know if that’s helpful of if I misunderstood the question.

---

<div class="post-metadata">

**Author:** ![lbwa](https://community.info-beamer.com/letter_avatar_proxy/v3/letter/l/4491bb/32.png) [@lbwa](https://community.info-beamer.com/u/lbwa)\
**Post date:** [February 20, 2019, 5:57pm UTC](https://community.info-beamer.com/t/getting-the-device-id-for-api/352/3 "2019-02-20T17:57:39Z")

</div>

The device is added automatic using the [custom download](https://info-beamer.com/doc/device-configuration#automaticallyaddadevicetoyouraccount) option. This way the device is added to my account, but I need at way to control the device via API from my own portal - so I need a way to connect the device with my device on my portal.

---

<div class="post-metadata">

**Author:** ![lbwa](https://community.info-beamer.com/letter_avatar_proxy/v3/letter/l/4491bb/32.png) [@lbwa](https://community.info-beamer.com/u/lbwa)\
**Post date:** [February 20, 2019, 6:01pm UTC](https://community.info-beamer.com/t/getting-the-device-id-for-api/352/4 "2019-02-20T18:01:12Z")

</div>

The question is: Is the Device\_ID the same as the “Serial Number” on the “Info Screen”?

---

<div class="post-metadata">

**Author:** ![infobeamer-fw](https://community.info-beamer.com/user_avatar/community.info-beamer.com/infobeamer-fw/32/3_2.png) [@infobeamer-fw](https://community.info-beamer.com/u/infobeamer-fw)\
**Post date:** [February 20, 2019, 6:14pm UTC](https://community.info-beamer.com/t/getting-the-device-id-for-api/352/5 "2019-02-20T18:14:58Z")

</div>

With the `connect` feature of the [custom download](https://info-beamer.com/doc/api#oscustomizeddownload), all that happens is that a device is automatically added to the account that created the download, so basically the `device/create` call happens automatically. Before a device is added it doesn’t have an identity.

Once its added and it has been assigned a setup based on the [screen info package](https://info-beamer.com/pkg/1248), you can match the devices if you compare the `serial` values from the [device/list](https://info-beamer.com/doc/api#listalldevices) response with the serial number shown on screen.

Back when that package was built, there was no easy way to know the device id in the code running on the device. This has changed now (thanks to the [\_\_metadata](https://info-beamer.com/doc/package-reference#configjsonmetadata) info in the generated config.json), so the package could also show the device id directly now. But that’s not implemented.

---

<div class="post-metadata">

**Author:** ![lbwa](https://community.info-beamer.com/letter_avatar_proxy/v3/letter/l/4491bb/32.png) [@lbwa](https://community.info-beamer.com/u/lbwa)\
**Post date:** [February 20, 2019, 7:12pm UTC](https://community.info-beamer.com/t/getting-the-device-id-for-api/352/6 "2019-02-20T19:12:52Z")

</div>

😉 Ok - next question: When will it be implemented?

---

<div class="post-metadata">

**Author:** ![infobeamer-fw](https://community.info-beamer.com/user_avatar/community.info-beamer.com/infobeamer-fw/32/3_2.png) [@infobeamer-fw](https://community.info-beamer.com/u/infobeamer-fw)\
**Post date:** [February 20, 2019, 7:19pm UTC](https://community.info-beamer.com/t/getting-the-device-id-for-api/352/7 "2019-02-20T19:19:48Z")

</div>

It’s pretty simple actually: Basically in this code that [loads the config.json file](https://github.com/info-beamer/package-screen-info/blob/d51a50feaf0b8079c8135437e2fd8c875e5c51f9/node.lua#L17-L20), just store the value of

```lua
device_id = config.__metadata.device_id

```

and then [later](https://github.com/info-beamer/package-screen-info/blob/d51a50feaf0b8079c8135437e2fd8c875e5c51f9/node.lua#L35-L36) render it on the screen. So it’s really 3 lines of code that needs changing. I can create a new branch that implements this tomorrow and you can them import it into your account.

---

<div class="post-metadata">

**Author:** ![lbwa](https://community.info-beamer.com/letter_avatar_proxy/v3/letter/l/4491bb/32.png) [@lbwa](https://community.info-beamer.com/u/lbwa)\
**Post date:** [February 20, 2019, 8:49pm UTC](https://community.info-beamer.com/t/getting-the-device-id-for-api/352/8 "2019-02-20T20:49:40Z")

</div>

It seems that I have misunderstood my developers. I didn’t think of the “initial setup hex number” as a “pin” 🙂

Forget everything…

Eveyone is happy 😉

---

<div class="post-metadata">

**Author:** ![infobeamer-fw](https://community.info-beamer.com/user_avatar/community.info-beamer.com/infobeamer-fw/32/3_2.png) [@infobeamer-fw](https://community.info-beamer.com/u/infobeamer-fw)\
**Post date:** [February 20, 2019, 9:17pm UTC](https://community.info-beamer.com/t/getting-the-device-id-for-api/352/9 "2019-02-20T21:17:39Z")

</div>

Ok. That saves me those 5 minutes adding the feature 🙂

---

<div class="post-metadata">

**Author:** ![lbwa](https://community.info-beamer.com/letter_avatar_proxy/v3/letter/l/4491bb/32.png) [@lbwa](https://community.info-beamer.com/u/lbwa)\
**Post date:** [February 21, 2019, 7:38am UTC](https://community.info-beamer.com/t/getting-the-device-id-for-api/352/10 "2019-02-21T07:38:11Z")

</div>

The reason for using the “auto add” feature and showing the “Device Info” was that I then could customize the initial screen a little with own logo.  
The standard Info-beamer screen shows “[info-beamer.com/devices](http://info-beamer.com/devices)” as the initial start screen.  
But maybe I should just create my own package 🙂

---

<div class="post-metadata">

**Author:** ![infobeamer-fw](https://community.info-beamer.com/user_avatar/community.info-beamer.com/infobeamer-fw/32/3_2.png) [@infobeamer-fw](https://community.info-beamer.com/u/infobeamer-fw)\
**Post date:** [February 21, 2019, 11:28am UTC](https://community.info-beamer.com/t/getting-the-device-id-for-api/352/11 "2019-02-21T11:28:49Z")

</div>

There is actually a (not yet documented) way to change that addess: Create `/config/branding.json` with the following content:

```auto
{
    "register-url": "example.com/register"
}

```

Of course if you register the device beforehand and pre-install a package, you can fully decide (and remotely update) how all that looks like. So if that’s an option, it’s a lot more flexible.

---

<div class="post-metadata">

**Author:** ![lbwa](https://community.info-beamer.com/letter_avatar_proxy/v3/letter/l/4491bb/32.png) [@lbwa](https://community.info-beamer.com/u/lbwa)\
**Post date:** [February 21, 2019, 11:41am UTC](https://community.info-beamer.com/t/getting-the-device-id-for-api/352/12 "2019-02-21T11:41:57Z")

</div>

I have actually made my first package. It was actually quite easy 🙂

So not I just auto register all new displays and uses my own module as default.
