←back to thread

224 points gurjeet | 10 comments | | HN request time: 0s | source | bottom
1. 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 #
2. mazamats ◴[] No.26633994[source]
Plus if you use curl, it will return JSON instead of HtML
replies(2): >>26634057 #>>26634323 #
3. klohto ◴[] No.26634057[source]
curl ifconfig.co/json
4. tyingq ◴[] No.26634321[source]
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

replies(1): >>26634890 #
5. 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 #
6. majkinetor ◴[] No.26634537{3}[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 #
7. mazamats ◴[] No.26634890[source]
The URL is cleaner with ipinfo.io, don't have to specify GET parameters with it.
8. JimDabell ◴[] No.26635532{4}[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 #
9. majkinetor ◴[] No.26635699{5}[source]
Doesnt work on Windows 10 using latest pwsh
replies(1): >>26636201 #
10. jodrellblank ◴[] No.26636201{6}[source]
Works on Windows 10 using Windows PowerShell. In Pwsh it does seem to need /json