Don't want to read anything else? Then don't, run the code sample below in your terminal to see some code magic!
$ curl 'https://api.seeip.org/jsonip?'
Have you ever needed to get an IPv4 or IPv6 address separately within your software or web app? Maybe you want to show your visitors both their IPv4 and IPv6 addresses at the same time or you want to test IPv6 readiness. With SeeIP you can do this and more!
You should use SeeIP because:
Using SeeIP is really easy. You have multiple options. You can retrieve an IP in text, JSON or JSONP format, and you can also retrieve the IP's Geolocation information. You can choose to get either IPv4 or IPv6 or only IPv4 or IPv6.
API URI | Response Type | Sample Output (IPv4) | Sample Output (IPv6) |
https://api.seeip.org |
text |
192.88.99.23 |
2a05:dfc7:5::53 |
https://api.seeip.org/jsonip |
json |
{"ip":"192.88.99.23"} |
{"ip":"2a05:dfc7:5::53"} |
https://api.seeip.org/jsonip?callback=getip |
jsonip |
getip({"ip":"192.88.99.23"}); |
getip({"ip":"2a05:dfc7:5::53"}); |
The endpoints below will only display IPv4 addresses.
API URI | Response Type | Sample Output |
https://ipv4.seeip.org |
text |
192.88.99.23 |
https://ipv4.seeip.org/jsonip |
json |
{"ip":"192.88.99.23"} |
https://ipv4.seeip.org/jsonip?callback=getip |
jsonip |
getip({"ip":"192.88.99.23"}); |
The endpoints below will only display IPv6 addresses.
API URI | Response Type | Sample Output |
https://ipv6.seeip.org |
text |
2a05:dfc7:5::53 |
https://ipv6.seeip.org/jsonip |
json |
{"ip":"2a05:dfc7:5::53"} |
https://ipv6.seeip.org/jsonip?callback=getip |
jsonip |
getip({"ip":"2a05:dfc7:5::53"}); |
Some common usage patterns from a variety of programming languages are outlined below.
#!/bin/bash
ip=$(curl -s https://ip.seeip.org)
echo "My public IP address is: $ip"
# 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.seeip.org').text
print('My public IP address is: {}'.format(ip))
require "net/http"
ip = Net::HTTP.get(URI("https://api.seeip.org"))
puts "My public IP Address is: " + ip
<?php
$ip = file_get_contents('https://api.seeip.org');
echo "My public IP address is: " . $ip;
?>
try (java.util.Scanner s = new java.util.Scanner(new java.net.URL("https://api.seeip.org").openStream(), "UTF-8").useDelimiter("\\A")) {
System.out.println("My current IP address is " + s.next());
} catch (java.io.IOException e) {
e.printStackTrace();
}
use strict;
use warnings;
use LWP::UserAgent;
my $ua = new LWP::UserAgent();
my $ip = $ua->get('https://api.seeip.org')->content;
print 'My public IP address is: '. $ip;
var httpClient = new HttpClient();
var ip = await httpClient.GetStringAsync("https://api.seeip.org");
Console.WriteLine($"My public IP address is: {ip}");
Dim httpClient As New System.Net.Http.HttpClient
Dim ip As String = Await httpClient.GetStringAsync("https://api.seeip.org")
Console.WriteLine($"My public IP address is: {ip}")
var http = require('http');
http.get({'host': 'api.seeip.org', 'port': 80, 'path': '/'}, function(resp) {
resp.on('data', function(ip) {
console.log("My public IP address is: " + ip);
});
});
package main
import (
"io/ioutil"
"net/http"
"os"
)
func main() {
res, _ := http.Get("https://api.seeip.org")
ip, _ := ioutil.ReadAll(res.Body)
os.Stdout.Write(ip)
}
(require net/url)
(define ip (port->string (get-pure-port (string->url "https://api.seeip.org"))))
(printf "My public IP address is: ~a" ip)
val addr = scala.io.Source.fromURL("https://api.seeip.org").mkString
println(s"My public IP address is: $addr")
<script type="application/javascript">
function getIP(json) {
document.write("My public IP address is: ", json.ip);
}
</script>
<script type="application/javascript" src="https://api.seeip.org?format=jsonp&callback=getIP"></script>
<script type="application/javascript">
$(function() {
$.getJSON("https://api.seeip.org?format=jsonp&callback=?",
function(json) {
document.write("My public IP address is: ", json.ip);
}
);
});
</script>
using System;
using System.Net;
namespace seeip.Examples {
class Program {
public static void Main (string[] args) {
WebClient webClient = new WebClient();
string publicIp = webClient.DownloadString("https://api.seeip.org");
Console.WriteLine("My public IP Address is: {0}", publicIp);
}
}
}
import HttpClient
var ip = newHttpClient().getContent("https://api.seeip.org")
echo("My public IP address is: ", ip)
$ip = Invoke-RestMethod -Uri 'https://api.seeip.org?format=json'
"My public IP address is: $($ip.ip)"
http.Fetch("https://api.seeip.org", function(body) print("My ip is: " .. body ) end
InitNetwork()
*Buffer = ReceiveHTTPMemory("https://api.seeip.org?format=json")
If *Buffer
ParseJSON(0, PeekS(*Buffer, MemorySize(*Buffer), #PB_UTF8))
FreeMemory(*Buffer)
Debug GetJSONString(GetJSONMember(JSONValue(0), "ip"))
EndIf
put "My public IP address is" && url "https://api.seeip.org"
if (client.connect("api.seeip.org", 80)) {
Serial.println("connected");
client.println("GET / HTTP/1.0");
client.println("Host: api.seeip.org");
client.println();
} else {
Serial.println("connection failed");
}
Calling the API endpoint without any parameter will return location information for the visitor IP address:
Appending an IP address as parameter will return location information for this IP address:
The output is a JSON object containing the following elements:
Please note that the IP location database, which for this API is Maxmind, may not contain all information about a given IP. In this case, only the available data is displayed.
The dma, continent, and area code information is not available and thus not present in the output JSON object:
{
"ip":"208.67.222.222",
"organization": "AS36692 OpenDNS, LLC",
"city": "San Francisco",
"region": "California",
"dma_code": "0",
"area_code": "0",
"timezone": "America\/Los_Angeles",
"offset": "-7",
"longitude": -122.3933,
"country_code3": "USA",
"postal_code": "94107",
"continent_code": "NA",
"country": "United States",
"region_code": "CA",
"country_code": "US","latitude":37.7697
}