Hacker News new | ask | show | jobs
by mazamats 1910 days ago
I prefer ipinfo.io

You can even lookup info for other up addresses. E.g. https://ipinfo.io/1.1.1.1

2 comments

This one supports other IPs also: https://ifconfig.co/?ip=1.2.3.4

And JSON: https://ifconfig.co/json?ip=1.2.3.4

The URL is cleaner with ipinfo.io, don't have to specify GET parameters with it.
Plus if you use curl, it will return JSON instead of HtML
If you use powershell / invoke-restmethod it will return json and get deserialised into a structured object, too.

    PS C:\> irm ipinfo.io

    PS C:\> $x = irm ipinfo.io
    PS C:\> $x.timezone
    Europe/London
Personally, I use http://checkip.dyndns.org/ by habit, with its one-line return.
No it wont, server need to return JSON format itself.

Your example doesn't work. It needs to be:

    irm ipinfo.io/json
Your other example can be get like this:

    irm http://checkip.dyndns.org | % HTML | % body
It will work. The server will return JSON. The URL http://ipinfo.io/ returns HTML if the Accept header indicates that you want HTML, and JSON if there is no header, a wildcard header, or a header that requests JSON. As far as I can see, irm doesn’t add an Accept header, so the command jodrellblank provided will fetch JSON and work correctly.
Doesnt work on Windows 10 using latest pwsh
Works on Windows 10 using Windows PowerShell. In Pwsh it does seem to need /json
curl ifconfig.co/json