Serving 5M+ queries per day

ipaddress.sh

Your public IP, instantly

terminal
$ 
Your IP Address Loading...

API Endpoints

Multiple response formats for your needs

GET ipaddress.sh
Plain Text 208.80.152.201
GET ipaddress.sh?format=json
JSON {"ip":"208.80.152.201"}
GET ipaddress.sh?format=jsonp
JSONP callback({"ip":"208.80.152.201"});
GET ipaddress.sh?format=jsonp&callback=getip
JSONP Custom getip({"ip":"208.80.152.201"});

Usage Examples

Get started in your favorite language

Terminal
curl https://ipaddress.sh
Using wget
wget -qO- https://ipaddress.sh
Python
import requests

response = requests.get('https://ipaddress.sh')
ip_address = response.text
print("Your IP address is:", ip_address)
JavaScript
const response = await fetch('https://ipaddress.sh');
const ipAddress = await response.text();
console.log("Your IP address is:", ipAddress);
Node.js 18+ (native fetch)
const response = await fetch('https://ipaddress.sh');
const ipAddress = await response.text();
console.log("Your IP address is:", ipAddress);
Go
package main

import (
  "fmt"
  "io"
  "net/http"
)

func main() {
  resp, err := http.Get("https://ipaddress.sh")
  if err != nil {
    fmt.Println("Error:", err)
    return
  }
  defer resp.Body.Close()

  ipAddress, _ := io.ReadAll(resp.Body)
  fmt.Println("Your IP address is:", string(ipAddress))
}
Rust (reqwest)
use reqwest::Error;

#[tokio::main]
async fn main() -> Result<(), Error> {
    let ip_address = reqwest::get("https://ipaddress.sh")
        .await?
        .text()
        .await?;

    println!("Your IP address is: {}", ip_address);
    Ok(())
}
Ruby
require 'net/http'

response = Net::HTTP.get(URI('https://ipaddress.sh'))
puts "Your IP address is: #{response}"
PHP
<?php
$ip_address = file_get_contents('https://ipaddress.sh');
echo "Your IP address is: " . $ip_address;
?>
Java
import java.net.http.*;
import java.net.URI;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://ipaddress.sh"))
            .build();

        HttpResponse<String> response = client.send(request,
            HttpResponse.BodyHandlers.ofString());

        System.out.println("Your IP address is: " + response.body());
    }
}
C#
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program {
    static async Task Main() {
        using var client = new HttpClient();
        string ipAddress = await client.GetStringAsync("https://ipaddress.sh");
        Console.WriteLine("Your IP address is: " + ipAddress);
    }
}
Swift
import Foundation

let url = URL(string: "https://ipaddress.sh")!
let task = URLSession.shared.dataTask(with: url) { data, _, error in
    guard let data = data, error == nil else { return }
    let ipAddress = String(data: data, encoding: .utf8)
    print("Your IP address is: \(ipAddress ?? "")")
}
task.resume()
Kotlin (ktor)
import io.ktor.client.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import kotlinx.coroutines.runBlocking

fun main() = runBlocking {
    val client = HttpClient()
    val ipAddress = client.get("https://ipaddress.sh").bodyAsText()
    println("Your IP address is: $ipAddress")
    client.close()
}

Ready to get started?

Just one simple API call away

Get Your IP Address