L2.IO

Get Client's IP Address from JSON, Javascript...and more

NEWS

2022-12-17: 8 locations worldwide.
2020-04-11: Added JSON support.
2019-04-22: Added 2 servers for
redundancy and load sharing.
2015-09-15: Serves now 4.500.000
requests per Day.
2015-07-03: Added an IPv4 only URL.
2015-06-24: Added IPv6 support.
2015-06-23: Serves now 2.500.000
requests per Day.
Tested at 6.000.000 per Hour.
2015-06-22: Corrected minor XSS
vulnerability.
2015-06-18: HTTPS is there !
2015-01-13: 1.200.000 Hits per Day.
Adding 1 more server.
2014-11-06: More than 660.000 Hits
per Day and growing !
2014-11-05: Servers has been tested
at 10.000.000 Hits per Day.
2014-10-20: We have now reach
300.000 Hits per Day !
2012-06-04: L2.IO API is launched!

COMMING SOON

A new Variable for Country Code

UNDER DEVELOPMENT

A new Variable for Country Name

Free. No Log. No Tracking. Ever!

Carrier-Grade service

99.9999% SLA

Since 2012

2.800.000.000 requests in the last 24 hours

Obtaining Visitor's IP Address using JSON

This basic API permits you to get the public IP address of the system making the call.
The function returns a JSON Text String with the IP address of the caller in either IPv4 or IPv6 format,
depending on the requester's protocol.

Syntax : https://l2.io/ip.json Try it!
Get JSON User's IP address
IPv4 32-bit (four-byte) format, e.g. 195.80.156.70
IPv6 128-bit format, e.g. 2a00:1b11:115:102:195:80:156:70

If your script only supports IPv4 answers, you may want to use the following call to force IPv4:

Syntax : https://www.l2.io/ip.json Try it!
Get JSON User's IP address
IPv4 32-bit (four-byte) format, e.g. 195.80.156.70
#curl https://l2.io/ip.json
{"ip":"195.80.156.70"}

#curl https://l2.io/ip.json?var=myip
{"myip":"195.80.156.70"}



Obtaining Visitor's IP Address in Javascript

This API permits you to set the Javascript Variable of your choice with the public IP address
of the system making the call.
The call returns a piece of Javascript Code with the IP address of the caller in either IPv4 or IPv6 format,
depending on your request's protocol.
The Variable Name is defined through the 'var' parameter.

Syntax : <script type="text/javascript" src="https://l2.io/ip.js?var=myip"></script>
Set javascript variable "myip" to client's IP address
IPv4 32-bit (four-byte) format, e.g. myip = "195.80.156.70";
IPv6 128-bit format, e.g. myip = "2a00:1b11:115:102:195:80:156:70";

If your script only supports IPv4 answers, you may want to use the following call instead :

Syntax : <script type="text/javascript" src="https://www.l2.io/ip.js?var=myip"></script>
Set javascript variable "myip" to client's IP address
IPv4 32-bit (four-byte) format, e.g. myip = "195.80.156.70";

The following lines could be inserted into your HTML page.
<script type="text/javascript">
  var userip;
</script>
...
<script type="text/javascript" src="https://l2.io/ip.js?var=userip"></script>
...
<script type="text/javascript">
  document.write("Your IP is :", userip);
</script>
Syntax : <script type="text/javascript" src="https://l2.io/ip.js"></script>
Display Client's IP address in your HTML page using javascript
--> document.write('x.x.x.x');



Get IP Address with a simple HTTP(s) request

This basic API permits you to get the public IP address of the system making the call.
The function returns a Text String with the IP address of the caller in either IPv4 or IPv6 format,
depending on your request's protocol.

Syntax : https://l2.io/ip Try it!
Diplay/Get Plain Text User's IP address
IPv4 32-bit (four-byte) format, e.g. 195.80.156.70
IPv6 128-bit format, e.g. 2a00:1b11:115:102:195:80:156:70

If your script only supports IPv4 answers, you may want to use the following call to force IPv4:

Syntax : https://www.l2.io/ip Try it!
Diplay/Get Plain Text User's IP address
IPv4 32-bit (four-byte) format, e.g. 195.80.156.70

The following examples show how you can use this API from various language.
#shell
perl
python
vb.net
#!/bin/sh
#Simple request using curl from a shell script.
#If your OS supports a dual stack IPv4/IPv6 you can add -4 or -6 option
#to force protocol selection, e.g. $(curl -4 -s https://l2.io/ip).

myip=$(curl -s https://l2.io/ip)
echo "My IP is $myip"
#!/usr/bin/perl
#Debian library : apt-get install libwww-perl
use LWP::UserAgent;

my $useragent = new LWP::UserAgent();
my $myip = $useragent->get('https://l2.io/ip')->content;
print 'My IP address is: '. $myip;
#!/usr/bin/env python
#Debian library : apt-get install python-requests
from requests import get

myip = get('https://l2.io/ip').text
print 'My IP address is: ', myip

Dim wc as New System.Net.WebClient
Dim myip as String = wc.DownloadString("https://l2.io/ip")

MessageBox.Show(myip)