Want to get started right away? Don't wait, run the code sample below in your terminal and check it out!

$ curl 'https://api.ipify.org?format=json'


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:

  • You can use it without limit (even if you're doing millions of requests per minute).
  • 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!
  • It works flawlessly with both IPv4 and IPv6 addresses, so no matter what sort of technology you're using, there won't be issues.
  • ipify is completely open source (check out the GitHub repository).
  • No visitor information is ever logged. Period.
  • Lastly, ipify is funded by Randall Degges, 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).

API URI Response Type Sample Output (IPv4) Sample Output (IPv6)
https://api.ipify.org text ?
https://api.ipify.org?format=json json {"ip":""} ?
https://api.ipify.org?format=jsonp jsonp callback({"ip":""}); ?
https://api.ipify.org?format=jsonp&callback=getip jsonp getip({"ip":""}); ?


This section contains some common usage patterns from a variety of programming languages. Want something included that isn't listed here? Email me!



ip=$(curl -s https://api.ipify.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.ipify.org').text
print 'My public IP address is:', ip


require "net/http"

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


    $ip = file_get_contents('https://api.ipify.org');
    echo "My public IP address is: " . $ip;


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;


Dim client as New System.Net.WebClient
Dim ip as String = client.DownloadString("https://api.ipify.org")


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);


val addr = scala.io.Source.fromURL("https://api.ipify.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 type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getIP"></script>


<script type="application/javascript">
  $(function() {
      function(json) {
        document.write("My public IP address is: ", json.ip);


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);


$ip = Invoke-WebRequest -Uri https://api.ipify.org
"My public IP address is: $ip"


*Buffer = ReceiveHTTPMemory("https://api.ipify.org?format=json")
If *Buffer
  ParseJSON(0, PeekS(*Buffer, MemorySize(*Buffer), #PB_UTF8))
  Debug GetJSONString(GetJSONMember(JSONValue(0), "ip"))


put "My public IP address is" && url "https://api.ipify.org"


NSURL *url = [NSURL URLWithString:@"https://api.ipify.org/"];
NSString *ipAddress = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSLog(@"My public IP address is: %@", ipAddress);


if (client.connect("api.ipify.org", 80)) {
    client.println("GET / HTTP/1.0");
    client.println("Host: api.ipify.org");
} else {
    Serial.println("connection failed");


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 me an email with the details and I'll gladly link to it!