Page Inspect
Internal Links
1
External Links
44
Images
5
Headings
41
Page Content
Title:ipify - A Simple Public IP Address API
Description:ipify API is a simple public IP address API, easy enough to integrate into any application in seconds.
HTML Size:34 KB
Markdown Size:11 KB
Fetched At:November 18, 2025
Page Structure
h1ipify API
h2A Simple Public IP Address API
h3Want to get started right away?Don't wait, run one of the code samples below in your terminal and check
it out!
h3If you need to get the geolocation data by IP, please refer to our IP Geolocation API
h2Why ipify?
h3You should use ipify because:
h2API Usage
h3IPv4
h3IPv6
h3Universal: IPv4/IPv6
h2Code samples
h3Bash
h3NGS (Next Generation Shell)
h3Python
h3Ruby
h3PHP
h3Java
h3Perl
h3C#
h3VB.NET
h3NodeJS
h3Go
h3Racket
h3Lisp
h3Xojo
h3Scala
h3Javascript
h3jQuery
h3C#
h3Elixir
h3nim
h3PowerShell
h3Lua
h3PureBasic
h3LiveCode
h3Objective-C
h3Swift
h3Arduino
h3AutoIT
h3SAS language
h2Libraries
Markdown Content
ipify - A Simple Public IP Address API
# ipify API
IP Geolocation API
About API usage Code samples Libraries
## A Simple Public IP Address API
### Want to get started right away?
Don't wait, run one of the code samples below in your terminal and check it out!
IPv4
$ curl 'https://api.ipify.org?format=json'
{"ip":"185.103.110.182"}
IPv4(v6)
$ curl 'https://api64.ipify.org?format=json'
{"ip":"2a00:1450:400f:80d::200e"}
### If you need to get the geolocation data by IP, please refer to our
IP Geolocation API
## Why ipify?
Ever needed to get your public IP address programmatically?
Maybe you're provisioning new cloud servers and need to know your IP -- maybe you're behind a corporate firewall and need to tunnel information -- whatever the reason: sometimes having a public IP address API is useful!
### You should use ipify because:
1
You can use it without limit (even if you're doing millions of requests per minute.
2
It works flawlessly with both IPv4 and IPv6 addresses, so no matter what sort of technology you're using, there won't be issues.
3
It's always online and available, and its infrastructure is powered by Heroku, which means that regardless of whether the server running the API dies, or if there's an enormous tornado which destroys half of the east coast, ipify will still be running!
4
ipify is completely open source (check out the GitHub repository).
5
No visitor information is ever logged. Period.
6
Lastly, ipify is open source so there's no need to worry about the domain name disappearing in three years or anything like that: ipify is here to stay!
## API Usage
Using ipify is ridiculously simple. You have three options. You can get your public IP directly (in plain text), you can get your public IP in JSON format, or you can get your public IP information in JSONP format (useful for Javascript developers).
### IPv4
API URL
Response Type
Sample Output (IPv4)
`https://api.ipify.org`
`text`
`98.207.254.136`
`https://api.ipify.org?format=json`
`json`
`{"ip":"98.207.254.136"}`
`https://api.ipify.org?format=jsonp`
`jsonp`
`callback({"ip":"98.207.254.136"});`
`https://api.ipify.org?format=jsonp&callback=getip`
`jsonp`
`getip({"ip":"98.207.254.136"});`
### IPv6
The api6.ipify.org is used for IPv6 request only. If you don't have an IPv6 address, the request will fail.
API URL
Response Type
Sample Output (IPv6)
`https://api6.ipify.org`
`text`
`2a00:1450:400f:80d::200e`
`https://api6.ipify.org?format=json`
`json`
`{"ip":"2a00:1450:400f:80d::200e"}`
`https://api6.ipify.org?format=jsonp`
`jsonp`
`callback({"ip":"2a00:1450:400f:80d::200e"});`
`https://api6.ipify.org?format=jsonp&callback=getip`
`jsonp`
`getip({"ip":"2a00:1450:400f:80d::200e"});`
### Universal: IPv4/IPv6
API URL
Response Type
Sample Output (IPv4/IPv6)
`https://api64.ipify.org`
`text`
`98.207.254.136 or 2a00:1450:400f:80d::200e`
`https://api64.ipify.org?format=json`
`json`
`{"ip":"98.207.254.136"} or {"ip":"2a00:1450:400f:80d::200e"}`
`https://api64.ipify.org?format=jsonp`
`jsonp`
`callback({"ip":"98.207.254.136"}); or callback({"ip":"2a00:1450:400f:80d::200e"});`
`https://api64.ipify.org?format=jsonp&callback=getip`
`jsonp`
`getip({"ip":"98.207.254.136"}); or getip({"ip":"2a00:1450:400f:80d::200e"});`
## Code samples
This section contains some common usage patterns from a variety of programming languages. Want something included that isn't listed here? Email us!
### Bash
#!/bin/bash
ip=$(curl -s https://api.ipify.org)
echo "My public IP address is: $ip"
### NGS (Next Generation Shell)
ip=`curl -s https://api.ipify.org`
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.ipify.org').text
print('My public IP address is: {}'.format(ip))
### Ruby
require "net/http"
ip = Net::HTTP.get(URI("https://api.ipify.org"))
puts "My public IP Address is: " + ip
### PHP
<?php
$ip = file_get_contents('https://api.ipify.org');
echo "My public IP address is: " . $ip;
?>
### Java
try (java.util.Scanner s = new java.util.Scanner(new java.net.URL("https://api.ipify.org").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.ipify.org')->content;
print 'My public IP address is: '. $ip;
### C#
var httpClient = new HttpClient();
var ip = await httpClient.GetStringAsync("https://api.ipify.org");
Console.WriteLine($"My public IP address is: {ip}");
### VB.NET
Dim httpClient As New System.Net.Http.HttpClient
Dim ip As String = Await httpClient.GetStringAsync("https://api.ipify.org")
Console.WriteLine($"My public IP address is: {ip}")
### NodeJS
var http = require('http');
http.get({'host': 'api.ipify.org', '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.ipify.org")
ip, _ := ioutil.ReadAll(res.Body)
os.Stdout.Write(ip)
}
### Racket
(require net/url)
(define ip (port->string (get-pure-port (string->url "https://api.ipify.org"))))
(printf "My public IP address is: ~a" ip)
### Lisp
;This example requires the drakma http package installed.
;It can be found here: http://www.weitz.de/drakma
(let ((stream
(drakma:http-request "https://api.ipify.org" :want-stream t)))
(let ((public-ip (read-line stream)))
(format t "My public IP address is: ~A" public-ip)))
### Xojo
Dim s As New HTTPSecureSocket
Dim t As String = s.Get("https://api.ipify.org",10)
MsgBox "My public IP Address is: " + t
### Scala
val addr = scala.io.Source.fromURL("https://api.ipify.org").mkString
println(s"My public IP address is: $addr")
### Javascript
<script type="application/javascript">
function getIP(json) {
document.write("My public IP address is: ", json.ip);
}
</script>
<script type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getIP"></script>
### jQuery
<script type="application/javascript">
$(function() {
$.getJSON("https://api.ipify.org?format=jsonp&callback=?",
function(json) {
document.write("My public IP address is: ", json.ip);
}
);
});
</script>
### C#
using System;
using System.Net;
namespace Ipify.Examples {
class Program {
public static void Main (string[] args) {
WebClient webClient = new WebClient();
string publicIp = webClient.DownloadString("https://api.ipify.org");
Console.WriteLine("My public IP Address is: {0}", publicIp);
}
}
}
### Elixir
:inets.start
{:ok, {_, _, inet_addr}} = :httpc.request('http://api.ipify.org')
:inets.stop
### nim
import HttpClient
var ip = newHttpClient().getContent("https://api.ipify.org")
echo("My public IP address is: ", ip)
### PowerShell
$ip = Invoke-RestMethod -Uri 'https://api.ipify.org?format=json'
"My public IP address is: $($ip.ip)"
### Lua
socket_http = require "http.compat.socket"
body = assert(socket_http.request("https://api.ipify.org"))
print(body)
### PureBasic
InitNetwork()
*Buffer = ReceiveHTTPMemory("https://api.ipify.org?format=json")
If *Buffer
ParseJSON(0, PeekS(*Buffer, MemorySize(*Buffer), #PB_UTF8))
FreeMemory(*Buffer)
Debug GetJSONString(GetJSONMember(JSONValue(0), "ip"))
EndIf
### LiveCode
put "My public IP address is" && url "https://api.ipify.org"
### Objective-C
NSURL *url = [NSURL URLWithString:@"https://api.ipify.org/"];
NSString *ipAddress = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSLog(@"My public IP address is: %@", ipAddress);
### Swift
import Foundation
let url = URL(string: "https://api.ipify.org")
do {
if let url = url {
let ipAddress = try String(contentsOf: url)
print("My public IP address is: " + ipAddress)
}
} catch let error {
print(error)
}
### Arduino
if (client.connect("api.ipify.org", 80)) {
Serial.println("connected");
client.println("GET / HTTP/1.0");
client.println("Host: api.ipify.org");
client.println();
} else {
Serial.println("connection failed");
}
### AutoIT
$b = TimerInit()
$Read = InetRead("https://api.ipify.org",1)
$sData = BinaryToString($Read)
MsgBox(64,"Information","Your IP Address: " & $sData & @CRLF & "Elapsed Time: " & StringLeft(TimerDiff($b) / 1000,4) & " seconds.")
### SAS language
filename ipresp "%sysfunc(pathname(work))\ipify-response.html";
proc http
url="https://api.ipify.org"
method=GET
out=ipresp
;
run;
data null;
length ip $ 20;
infile ipresp recfm=f lrecl=32000 encoding='utf-8' truncover;
input ip :$20.;
**Create a macro variable "IP" with the ip address: ;
call symput('IP',cats(ip));
**Print the ip address to the log: ;
put 'NOT' 'E: >>>>>>>>>>>> Official IP: ' ip ' <<<<<<<<<<<<<<<<<<';
run;
filename ipresp;
## Libraries
If you want to use ipify in your favorite programming language, but want to keep your code nice and tidy, feel free to use one of our libraries below! They'll make your life a little bit easier and more enjoyable =)
NOTE: Don't see a library for your favorite programming language? If you create one, I'll be happy to link to it below! Just shoot us an email with the details and I'll gladly link to it!
Library URL
Language
Author
Official?
`https://github.com/rdegges/go-ipify`
`Go`
`Randall Degges`
`yes`
`https://github.com/rdegges/python-ipify`
`Python`
`Randall Degges`
`yes`
`https://github.com/xtonousou/ipify.sh`
`Bash`
`Sotirios M. Roussis`
`no`
`https://github.com/troglobit/lipify`
`C`
`Joachim Nilsson`
`no`
`https://github.com/sideshowcoder/ipify-c`
`C`
`Philipp Fehre`
`no`
`https://github.com/sindresorhus/ipify`
`Node.js`
`Sindre Sorhus`
`no`
`https://github.com/davidepedrazzi/ipify2`
`Node.js`
`Davide Pedrazzi`
`no`
`https://bitbucket.org/stevenjeffries/java-ipify`
`Java`
`Steven Jeffries`
`no`
`https://github.com/vincent-peng/swift-ipify`
`Swift`
`Vincent Peng`
`no`
`https://github.com/gabulyaz/elixir-ipify`
`Elixir`
`Zoltán Gabulya`
`no`
`https://github.com/benjamin-smith/php-ipify`
`PHP`
`Benjamin Smith`
`no`
`https://github.com/gregce/ipify`
`R`
`Greg Ceccarelli`
`no`
`https://github.com/aprendexojo/ipify`
`Xojo`
`Javier Rodriguez`
`no`
`https://github.com/Chuongv/CHVIpify`
`Objective-C`
`Chuong Vu`
`no`
`https://github.com/davidmus/Ipify.NET`
`.NET`
`David Musgrove`
`no`
`https://github.com/mauricioabreu/crystal-ipify`
`Crystal`
`Mauricio de Abreu Antunes`
`no`
`https://github.com/keltia/ipify-rs`
`Rust`
`Ollivier Robert`
`no`
`https://github.com/surrenderoz/ipify-public-ip`
`Rust`
`Surendra Verma`
`no`
`https://github.com/coldnew/ipify.clj`
`Clojurescript`
`Yen-Chin Lee`
`no`
`https://github.com/Bujupah/dart_ipify`
`Dart`
`Khalil Mejdi`
`no`
`https://github.com/chintan369/Ipify-Android`
`Kotlin`
`Chintak Patel`
`no`
ipify.org © 2014 - 2019