Serving 2M-3M queries per day

ipaddress.sh

Simple service to get the public IP address

terminal
$ 
Your IP Address 52.86.33.27

API Endpoints

Multiple response formats for your needs

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

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 (Browser)
fetch('https://ipaddress.sh')
  .then(response => response.text())
  .then(ipAddress => {
    console.log("Your IP address is:", ipAddress);
  });
Node.js (node-fetch)
const fetch = require('node-fetch');

fetch('https://ipaddress.sh')
  .then(response => response.text())
  .then(ipAddress => {
    console.log("Your IP address is:", ipAddress);
  });
Go
package main

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

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

  ipAddress, _ := ioutil.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 kotlinx.coroutines.runBlocking

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

Ready to get started?

Just one simple API call away

Get Your IP Address