Skip to main content

API to get your public IP and other HTTP request metadata

Often times we face the need to get our public IP address; in doing so, from time to time, we've used many URL endpoints, found in the wild - which seem to serve well for a while before disappearing suddenly, forever. As a permanent fix to this dilemma, i've written a tiny app and created couple of URL endpoints on my domain to get the public IP address and some HTTP request metadata over HTTP.

Currently, i've exposed two endpoints:

  • /public/ip/: To get the public IP address
  • /public/meta/: To get a few HTTP request metadata

The output will be in json for scalability.

Here is a curl workflow:

% curl
{"client_ip": ""}

% curl
{"client_ip": "", "client_port": "50111", "http_protocol": "HTTP/1.1", "request_method": "GET", "user_agent": "curl/7.47.0"}

Taking help from jq to prettify the json output:

% curl -s | jq .
  "client_ip": ""

% curl -s | jq .
  "client_ip": "",
  "client_port": "50115",
  "http_protocol": "HTTP/1.1",
  "request_method": "GET",
  "user_agent": "curl/7.47.0"


Comments powered by Disqus