web client public ip address

Is there a way to get the client's public ip address through the web application.
if it exists, can you give an example?

You can try something like this. There's other data that is returned along with the IP address.

procedure TForm1.WebButton1Click(Sender: TObject);
  Internet: String;
  Internet := 'Unknown';
    var ipdata = await fetch('https://ipapi.co/json/').then(function(response) {return response.json()});
    Internet = ipdata.ip

Here's what you might see in the console:

  asn: "AS6317"
  city: "Vancouver"
  continent_code: "NA"
  country: "CA"
  country_area: 9984670
  country_calling_code: "+1"
  country_capital: "Ottawa"
  country_code: "CA"
  country_code_iso3: "CAN"
  country_name: "Canada"
  country_population: 37058856
  country_tld: ".ca"
  currency: "CAD"
  currency_name: "Dollar"
  in_eu: false
  ip: ""
  languages: "en-CA,fr-CA,iu"
  latitude: 49.2584
  longitude: -123.1456
  network: ""
  org: "SHAW"
  postal: "V6J"
  region: "British Columbia"
  region_code: "BC"
  timezone: "America/Vancouver"
  utc_offset: "-0700"
  version: "IPv4"

I think this is easier done on the server. I don't think there is a direct way you can do this in javascript, but I guess you could call IP Address API

Thanks, AndrewSimard, this worked, but I have to have this server with me.

So I will also consider Russell Weetch's suggestion

What do you mean by "I have to have this server with me"?

My ```

1 Like

Thank you, I solved the server too!

Can you post a version of what you ended up using?

on the server side
My ```'https://ipapi.co/json/ '


AResponseInfo.ContentText := ARequestInfo.RemoteIP