ipapi.xyz - IP info JSON/text API

ipapi.xyz is a straightforward API that provides you with:

Usage

ipapi.xyz offers both an extended JSON endpoint and a simple response with only your IP. This last option is very useful in a CLI scenario, because you can get your IP address with just a cURL one-liner (see the example below).

http://ipapi.xyz/json

Response:

{
    "ip": "54.162.107.122",
    "hostname": "ec2-54-162-107-122.compute-1.amazonaws.com",
    "geo": {
        "continent_code": "NA",
        "country_code": "US",
        "country_code3": "USA",
        "country_name": "United States",
        "region": "VA",
        "city": "Ashburn",
        "postal_code": "20149",
        "latitude": 39.048099517822,
        "longitude": -77.472801208496,
        "dma_code": 511,
        "area_code": 703
    },
    "request_info": {
        "accept": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8",
        "accept-encoding": "x-gzip, gzip, deflate",
        "user-agent": "CCBot\/2.0 (http:\/\/commoncrawl.org\/faq\/)"
    },
    "retrievedAt": {
        "unix_timestamp": "1506332915",
        "rfc2822": "Mon, 25 Sep 2017 09:48:35 +0000"
    }
}

http://ipapi.xyz/ip or http://ipapi.xyz/text

Response:

54.162.107.122

Technical note: most information is obtained using the corresponding PHP functions, so you can expect the corresponding behaviour as provided in the PHP documentation. For instance, if the hostname is not available (no rDNS record was found), the API will return your IP address as your hostname. This is exactly what the gethostbyaddr function does. It will not return null, or remove the hostname field entirely.

HTTPS support: just replace http with https to enable it. Traditional HTTP requests are not redirected on purpose: many users of this API might not support encryption, for instance embedded or IoT devices.

Some usage examples

let url = URL(string: "https://ipapi.xyz/ip")
do {
  let ip = try String(contentsOf: url)
} catch {
  // network error
}
NSString *ipAddr = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"https://ipapi.xyz/ip"] encoding:NSUTF8StringEncoding error:nil];
$conn = curl_init();
curl_setopt($conn, CURLOPT_URL, "http://ipapi.xyz/ip");
curl_setopt($conn, CURLOPT_RETURNTRANSFER, 1);
$ip = curl_exec($conn);
curl_close($conn);
echo $ip;
(require net/url)
; ip-addr is String
(define ip-addr (port->string (get-pure-port (string->url "https://ipapi.xyz/ip"))))
andrea@cogitatio:~ $ curl ipapi.xyz/ip
54.162.107.122
andrea@cogitatio:~ $

I'm only providing a few examples here. If you have implemented the API in another programming language, send me your snippet at andrea {at} ipapi {dot} xyz. The more exotic the language is, the better! I'm hoping to publish a huge page with as many usage examples as possible.

Get downtime notifications

If you use the API and your software relies on it, I recommend that you subscribe using the form below. The mailing list is handled by MailChimp.

If you subscribe, I will keep you updated, especially if I have to take the API down for maintenance or if for some reason I have to shut down the entire service (I expect this will not happen in the near future!). No spammy emails, promised.

Limitations

Currently, there is no automatic rate limiting implemented. 😊

However, I reserve the right to block your IP if I receive an unreasonable amount of requests.

Known issues, to-do & support

Please contact me at andrea {at} ipapi {dot} xyz for issues or bugs.