To detect the IP address of the client computer that connects to your HTTP service, for instance, you can parse a response to a request your code sends to a service like 2ip.me ()
Here is a description of their API services:
You might be interested in the "Provider-IP API" service.