# Can I get the device's WiFi or host name, local IP or other device identifier?

**URL:** https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641
**Category:** Questions about Thunkable X
**Tags:** webapp
**Created:** [October 19, 2021, 8:58pm UTC](https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641 "2021-10-19T20:58:59Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![hdawc](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/hdawc/32/119068_2.png) [@hdawc](https://community.thunkable.com/u/hdawc)
#### Post date: [October 19, 2021, 8:59pm UTC](https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641/1 "2021-10-19T20:59:00Z")

</div>

I’m using a WebApp (not referring to a webview), to display data on a large screen. The data itself is irrelevant.

What I need to do is have the WebApp get some data from either the device (Raspberry Pi running Chrome) or the local network, that tells the WebApp something unique about this device that is running the WebApp.

For example, the local IP, or a device ID that I can reference in the WebApp itself. If Push Notifications worked I could use the OneSignal ID. But it doesn’t.

I saw actech’s demo app that gets some device data and IP via AJAX, but that isn’t specific to the device.

The route I would like to have is:  
device starts \> WebApp runs on chrome \> WebApp looks for device specific info \> checks with database \> displays data relevant to that device.

The thing is, because it’s all remote I can’t just set it up again if the power goes off etc. which is why I need the device to identify itself, without human interaction.  
If it was running as an app i.e. on a mobile there would be no problem, I could use OneSignal or just ensure persistent storage, or both.  
But with a WebApp, it has to survive power failures and reboots. Which this does not.

I tried putting the WebApp in an iframe and getting the parent URL using a webview (and JS), and having the iframe set to `referrerpolicy=strict-origin` or `unsafe-url`, but that doesn’t work.

I also can’t use `ThunkableWebviewerExtension.postMessage` to post _into_ an iframe from the host page. the postMessage has to be within a webview already in the WebApp, which is not what I need.

Basically; is there anyway to get external **device or local information** into the app?

Thank you.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [October 20, 2021, 11:42am UTC](https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641/2 "2021-10-20T11:42:34Z")

</div>

The easiest is to use the `Web API` component and use `https://api.ipify.org/` or `https://api.ipify.org?format=json`.

This will return the local IP address of the machine/device.

---

<div class="post-metadata">

### Author: ![hdawc](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/hdawc/32/119068_2.png) [@hdawc](https://community.thunkable.com/u/hdawc)
#### Post date: [October 21, 2021, 2:11pm UTC](https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641/3 "2021-10-21T14:11:14Z")

</div>

Hi,

This gets the public IP address, I’m looking for my internal one i.e. 192.168.1.123

What I meant by external device info in the above post was data from outside the webapp, not the external IP, sorry for any confusion.

I did some reading and it seems like getting the local IP through any kind of API (or even JS) is a security issue and unsupported by most methods.

So I’m looking into alternatives such as:

1. Running android on the raspberry pi so I can export the android app and use one-signal’s ID to register the device
2. Creating separate projects (though I already have 50 apps…)

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [October 25, 2021, 3:01pm UTC](https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641/4 "2021-10-25T15:01:11Z")

</div>

> [@hdawc](#):
>
> This gets the public IP address, I’m looking for my internal one i.e. 192.168.1.123

I looked into the issue and basically, reading the local IP of the client is regarded a security issue.

To go around it you can do one of two solutions

- Write a PHP script to listen to client requests and return back the client IP and load it in your server. then create a JavaScript code to request info from the server to get the client IP.

- In chrome, by default the local IP is hidden. use the `chrome;//flags` to disable this feature  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/d/0d56101f77b23f2ae480dc90dcb9b91f0678d180.png)  
Then use `webTRC calls` to read the local IP.

You may test with this sample code.

```auto
<!DOCTYPE html>
<html>
  
<head>
    <title>Getting Clients IP</title>
</head>
    <body>
        <div id="list"></div>  
        <script >  

        const ip = new Promise((resolve, reject) => {
        const conn = new RTCPeerConnection()
        conn.createDataChannel('')
        conn.createOffer(offer => conn.setLocalDescription(offer), reject)
        conn.onicecandidate = ice => {
            if (ice && ice.candidate && ice.candidate.candidate) {
                document.getElementById('list').innerHTML = ice.candidate.candidate.split(' ')[4];
            resolve(ice.candidate.candidate.split(' ')[4])
            conn.close()
            }
        }
        })
        </script>   
    </body>
</html>

```

Note that when this feature is enabled, you will get a long alphanumeric string with `.local` at the end.  
`bbc39f77-55e0-47c5-9975-96819229c21a.local`

Hope this helps.

---

<div class="post-metadata">

### Author: ![vishruth-ram](https://avatars.discourse-cdn.com/v4/letter/v/82dd89/32.png) [@vishruth-ram](https://community.thunkable.com/u/vishruth-ram)
#### Post date: [October 27, 2021, 1:42pm UTC](https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641/5 "2021-10-27T13:42:02Z")

</div>

What platform to write on?

> [@muneer](#):
>
> bbc39f77-55e0-47c5-9975-96819229c21a

What’s this?

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [October 27, 2021, 1:52pm UTC](https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641/6 "2021-10-27T13:52:59Z")

</div>

> [@vishruth-ram](#):
>
> What platform to write on

This is platform independent. It will show when you run the JavaScript I attached instead of the local IP address but if you disable the option I showed you and run the script again, you will see the local IP address.

---

<div class="post-metadata">

### Author: ![vishruth-ram](https://avatars.discourse-cdn.com/v4/letter/v/82dd89/32.png) [@vishruth-ram](https://community.thunkable.com/u/vishruth-ram)
#### Post date: [October 27, 2021, 1:56pm UTC](https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641/7 "2021-10-27T13:56:29Z")

</div>

ok now going for a test.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [October 27, 2021, 2:06pm UTC](https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641/8 "2021-10-27T14:06:58Z")

</div>

If you are connected via a WIFI then you can do the test by executing the script in one tab and see the output while in the other tab run `https://api.ipify.org/`

ipify will always give the internet provider IP address while the script I shared will give the WIFI IP address only when the **Anonymize local IP exposed by WebRTC** option is disabled. If the option is enabled then you will get this long arbitrary number ending with **.local**

Have fun.

---

<div class="post-metadata">

### Author: ![vishruth-ram](https://avatars.discourse-cdn.com/v4/letter/v/82dd89/32.png) [@vishruth-ram](https://community.thunkable.com/u/vishruth-ram)
#### Post date: [October 29, 2021, 2:15am UTC](https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641/9 "2021-10-29T02:15:05Z")

</div>

> [@muneer](#):
>
> If you are connected via a WIFI then you can do the test by executing the script in one tab and see the output while in the other tab run `https://api.ipify.org/`

ok now.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/a/9a6b9fa112e65f0bea1b6607800708d3dd76d854.png)  
😠how dare you find my IP adress!

---

<div class="post-metadata">

### Author: ![hdawc](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/hdawc/32/119068_2.png) [@hdawc](https://community.thunkable.com/u/hdawc)
#### Post date: [November 15, 2021, 2:41am UTC](https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641/10 "2021-11-15T02:41:53Z")

</div>

@super-coder just google “my ip” and it will tell you, there are millions of websites that log your IP address, even Google Analytics does it.

It’s no secret, probably 95%+ of websites you visit will monitor/log your IP address, including this forum.

---

<div class="post-metadata">

### Author: ![vishruth-ram](https://avatars.discourse-cdn.com/v4/letter/v/82dd89/32.png) [@vishruth-ram](https://community.thunkable.com/u/vishruth-ram)
#### Post date: [November 17, 2021, 11:03am UTC](https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641/11 "2021-11-17T11:03:15Z")

</div>

whatever this is solved and no other solutions are aceepted again.

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:14pm UTC](https://community.thunkable.com/t/can-i-get-the-devices-wifi-or-host-name-local-ip-or-other-device-identifier/1570641/12 "2024-11-08T13:14:46Z")

</div>


