IP Info User Guide


IP Info is a handy online tool/service that you can use to find out what your IP address is and various details about it.

There are plenty of other services out there that offer the exact same thing, and probably better. So I am only re-inventing the wheel here, but a wheel I have enjoyed building and learning along the way. It is also a tool I personally find very useful and use frequently myself.

Under the hood it uses an API provided by ipgeolocation for the lookup data. It is only on a free/developer plan and so is limited to 1000 requests per day, but results are cached for 24 hours and there are mechanisms in place to help limit the number of requests in a fairly intelligent way throughout the day ... hopefully, we'll see!

There is no UI on the website to enter a different IP, however you can still do so by entering it directly into the URL, like so...

joeka.net/ip/9.9.9.9

Try it now...

If you want to see some, not very interesting, debug information then add the querystring ?debug=true to the URL, like so...

joeka.net/ip/9.9.9.9?debug=true

Try it now...

Command Line

What I really liked about some of the other services out there was the ability to easily use the tool in the command line with something like curl, so I wanted to offer the same.

Using via the command line has plenty of options...

joeka.net/ip/{opt1}/{opt2}{?debug=true}

Both opt1 and opt2 are optional and interchangable (doesn't matter what order they appear).

The following values are supported...

  • Any valid IP address, e.g. 9.9.9.9. If none is specified then the IP address of the current request is used.
  • all - returns all information available.
  • info - returns a summary including the hostname and location.
  • location - returns city, state, country as a single string.
  • country - returns the country along with country code.
  • city - returns the city.
  • hostname or host - returns the hostname of the IP (if known).
  • state or province - returns the state or province.
  • If no options are specified then only the IP address is returned.

You can only specify a maximum of one IP address and one other option per request.

?debug=true is optional and must be at the end of the URL. If specified then additional debug information is included.

Response Options

By default all responses are returned as text/html as if the request has come from a standard web browser.

However, a command line request is automatically detected based on one of the following conditions...

  • UserAgent header starts with curl or wget
  • Accept header is text/plain or application/json

If a command line request is detected, then the response is always returned as text/plain unless application/json is specified.

Examples

Fetch the IP address of the current request...

curl joeka.net/ip
1.2.3.4

Fetch information about a different IP address...

curl joeka.net/ip/9.9.9.9
    IP Address: 9.9.9.9
      Hostname: dns9.quad9.net
           ISP: Quad9
  Organisation: Quad9
    User Agent: curl/8.0.1
     Continent: Europe (EU)
       Country: Switzerland (CH)
State/Province: Zurich
          City: Zurich
      Zip Code: 8004
     Languages: de-CH,fr-CH,it-CH,rm
      Timezone: Europe/Zurich (+1)
      Currency: Swiss Franc (CHF)
  Calling Code: +41
           TLD: .ch

When you request a different IP address it will return all details by default, but you can specify other options instead, like so...

curl joeka.net/ip/9.9.9.9/location
Zurich, Switzerland
curl joeka.net/ip/hostname/9.9.9.9
dns9.quad9.net

Note how with the hostname example above it came before the IP in the URL this time. This is just to demonstrate that it doesn't matter what order these options are specified.

With debugging information included...

curl joeka.net/ip/9.9.9.9/location?debug=true
Zurich, Switzerland

*** DEBUG INFO ***
      From Cache: Yes
          Cached: 13/10/2023 01:02:03
  Total Attempts: 1
    Last Attempt: 13/10/2023 01:02:02
Total Successful: 1
 Last Successful: 13/10/2023 01:02:03
    Max. per day: 1000
    Next Allowed: 13/10/2023 01:02:03

How about some JSON...

curl joeka.net/ip/9.9.9.9/json
{
  "lookupDateTime": "2023-10-13T01:58:00.9488696Z",
  "ipAddress": "9.9.9.9",
  "asn": null,
  "callingCode": "\u002B41",
  "city": "Zurich",
  "continentCode": "EU",
  "continentName": "Europe",
  "countryCapital": "Bern",
  "countryFlagUrl": "https://ipgeolocation.io/static/flags/ch_64.png",
  "countryName": "Switzerland",
  "countryTLD": ".ch",
  "countryCode2": "CH",
  "countryCode3": "CHE",
  "currencyCode": "CHF",
  "currencyName": "Swiss Franc",
  "currencySymbol": "CHF",
  "district": "",
  "geoNameId": "12003391",
  "hostname": "dns9.quad9.net",
  "isp": "Quad9",
  "languages": "de-CH,fr-CH,it-CH,rm",
  "latitude": "47.37328",
  "longitude": "8.53113",
  "organisation": "Quad9",
  "stateProvince": "Zurich",
  "timeZoneName": "Europe/Zurich",
  "timeZoneOffset": 1,
  "zipCode": "8004",
  "userAgentString": "curl/8.0.1"
}

Whenever you request JSON, all data is always returned.

Specifying an accept header of application/json will also return the full JSON result...

curl -H "Accept: application/json" joeka.net/ip

Supposing the user agent of the tool you're using does not start with curl or wget, but you still want to return a plain text result. In this example we simulate a request with a different User-Agent, which by default will return text/html, but if text/plain is requested, then that is what it will return instead...

curl -H "User-Agent: joeka browser v0.1" -H "Accept: text/plain" joeka.net/ip/9.9.9.9/info
IP Address: 9.9.9.9
  Hostname: dns9.quad9.net
  Location: Zurich, Switzerland

Related Articles

How to keep your instance of Pi-Hole up-to-date.

Networking

How to keep your instance of Pi-Hole up-to-date.

Networking

How to mount to a CIFS based network share from a Raspberry PI.

Raspberry PI, Linux, Networking

A quick and simple HTTP server in Python in only a few lines of code.

Raspberry PI, Python