Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting my public IP via API [closed]

Tags:

ip

api

Is there a public API from some big company to get my public ip from within a program?

I've found http://ip-address.domaintools.com/myip.xml, which is exactly what I want, but unfortunately it blocks Python's urllib as well as many other http libraries, unless you spoof user-agent (anything doing that can't be called an API at all).

The problem is that I need this data for some potentially open source library, so we have to play by the rules. I also know that I can just do smth like print $_SERVER[REMOTE_ADDR], but I don't want to server traffic to everyone using my library.

So, is there something like the URL above, but real API, that allows robots?

like image 927
Slava V Avatar asked Jun 22 '10 22:06

Slava V


People also ask

How do I find public IP address programmatically?

you need to create a function in Activity. class file, and need to request a url that will give your public IP in text form: "https://api.ipify.org/. Click to open. Add this function call in your onCreate() function.

How do I find the IP address of API?

IP addresses of API Management service You can retrieve the IP addresses from the overview dashboard of your resource in the Azure portal. In multi-regional deployments, each regional deployment has one public IP address.

How can I check my public IP status?

You can find your public IP address by searching "what is my IP" on Google. A private IP address can be assigned to your computers, mobiles, tablets, or any other machine within your private network without exposing them to the internet world. Its scope is local and is used to communicate within the local network.


1 Answers

While not from big companies, all of these should work:

curl icanhazip.com curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: \([0-9\.]*\).*/\1/g' host -t a dartsclink.com | sed 's/.*has address //' curl curlmyip.com curl ifconfig.me # this has a lot of different alternatives too, such as ifconfig.me/host 

Source

  • http://www.commandlinefu.com/commands/view/2966/return-external-ip#comment
like image 160
Jamie Wong Avatar answered Oct 11 '22 15:10

Jamie Wong