IP.la

Current IP: 35.175.182.106

Why use?

Do you need to get the public IP address or IP Geolocation programmatically? Do you have the requirements to obtain the servers’ public IP address? Do you need to get the location of your servers? Whatever the reason,sometimes a public IP address and IP Geolocation API are useful.

You should use IP.la because:

  • You can initiate requests without any limit.
  • You can get the english or chinese location data.
  • Does not record the visitor information.
  • Lastly, IP.la is sponsored by IPIP.NET and will exist in long-term stability, please feel free to use it.

API Usage

Using IP.la is ridiculously simple. You have two options. Address location support English and Chinese. You can get your public IP directly (in plain text), you can get your public IP in JSON format.

- API URI Type Sample Output (IPv4) Sample Output (IPv6)
get IP https://api.ip.la text 8.8.8.8 2001:4860:4860::8888
get XFF(X-Forwarded-For) https://api.ip.la/xff text 8.8.8.8 2001:4860:4860::8888
get IP Location(English) https://api.ip.la/en?json json
{
    "ip":"172.104.94.100",
    "location":{
        "country_code":"JP",
        "country_name":"Japan",
        "province":"Tokyo",
        "city":"Shinagawa",
        "latitude":"35.6130514",
        "longitude":"139.7344198"
    }
}
Coming soon
get IP Location(Chinese Simplified) https://api.ip.la/cn?json json
{
    "ip":"172.104.94.100",
    "location":{
        "country_code":"JP",
        "country_name":"日本",
        "province":"东京都",
        "city":"品川区",
        "latitude":"35.6130514",
        "longitude":"139.7344198"
    }
}
Coming soon

Gets the information for the request.

- API URI Type Sample Output
get Request Header https://api.ip.la/header text
GET /header HTTP/1.1
Host: api.ip.la
Accept: */*
User-Agent: curl/7.54.0

Examples

This section contains some common usage patterns from a variety of programming languages. Email me!

Bash

#!/bin/bash

ip=$(curl -s https://api.ip.la)
echo "My public IP address is: $ip"

Python

# This example requires the requests library be installed.  You can learn more
# about the Requests library here: http://docs.python-requests.org/en/latest/
from requests import get

ip = get('https://api.ip.la').text
print('My public IP address is: {}'.format(ip))

Ruby

require "net/http"

ip = Net::HTTP.get(URI("https://api.ip.la"))
puts "My public IP Address is: " + ip

PHP

<?php
    $ip = file_get_contents('https://api.ip.la');
    echo "My public IP address is: " . $ip;
?>

Java

try (java.util.Scanner s = new java.util.Scanner(new java.net.URL("https://api.ip.la").openStream(), "UTF-8").useDelimiter("\\A")) {
    System.out.println("My current IP address is " + s.next());
} catch (java.io.IOException e) {
    e.printStackTrace();
}

Perl

use strict;
use warnings;
use LWP::UserAgent;

my $ua = new LWP::UserAgent();
my $ip = $ua->get('https://api.ip.la')->content;
print 'My public IP address is: '. $ip;

C#

var httpClient = new HttpClient();
var ip = await httpClient.GetStringAsync("https://api.ip.la");
Console.WriteLine($"My public IP address is: {ip}");

NodeJS

var http = require('http');

http.get({'host': 'api.ip.la', 'port': 80, 'path': '/'}, function(resp) {
  resp.on('data', function(ip) {
    console.log("My public IP address is: " + ip);
  });
});

Go

package main

import (
        "io/ioutil"
        "net/http"
        "os"
)

func main() {
        res, _ := http.Get("https://api.ip.la")
        ip, _ := ioutil.ReadAll(res.Body)
        os.Stdout.Write(ip)
}

Connection

Request-Header

GET / HTTP/1.1
Host: www.ip.la
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip
Connection: Keep-Alive
If-Modified-Since: Mon, 15 Oct 2018 21:21:48 UTC
User-Agent: CCBot/2.0 (https://commoncrawl.org/faq/)