←back to thread

224 points gurjeet | 4 comments | | HN request time: 0.42s | source
Show context
mazamats ◴[] No.26633984[source]
I prefer ipinfo.io

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

replies(2): >>26633994 #>>26634321 #
mazamats ◴[] No.26633994[source]
Plus if you use curl, it will return JSON instead of HtML
replies(2): >>26634057 #>>26634323 #
jodrellblank ◴[] No.26634323[source]
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.
replies(1): >>26634537 #
1. majkinetor ◴[] No.26634537[source]
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
replies(1): >>26635532 #
2. JimDabell ◴[] No.26635532[source]
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.
replies(1): >>26635699 #
3. majkinetor ◴[] No.26635699[source]
Doesnt work on Windows 10 using latest pwsh
replies(1): >>26636201 #
4. jodrellblank ◴[] No.26636201{3}[source]
Works on Windows 10 using Windows PowerShell. In Pwsh it does seem to need /json