ipify API
api.ipify.org · Developer Tools
Simple public IP address API — returns your current public IP address in plain text or JSON. No API key required. 65+ billion requests served.
Authentication
No authentication requiredFree to use with no key needed.
Sample Requests
GET
Get your IP
Get your public IP address as plain text.
https://api.ipify.org
Hover any highlighted part to learn what it does
curl -X GET "https://api.ipify.org/"
import requests
response = requests.get(
"https://api.ipify.org/",
)
print(response.json())const url = 'https://api.ipify.org/'; const response = await fetch(url); const data = await response.json(); console.log(data);
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
targetURL := "https://api.ipify.org/"
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.ipify.org/")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.ipify.org/";
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET
Get IP as JSON
Get your public IP address as JSON.
https://api.ipify.org?format=json
Hover any highlighted part to learn what it does
curl -X GET "https://api.ipify.org/?format=json"
import requests
params = {
"format": "json"
}
response = requests.get(
"https://api.ipify.org/",
params=params,
)
print(response.json())const url = new URL('https://api.ipify.org/');
url.searchParams.set('format', 'json');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.ipify.org/")
q := baseURL.Query()
q.Set("format", "json")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.ipify.org/")
uri.query = URI.encode_www_form({
"format" => "json"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.ipify.org/?" . http_build_query([
"format" => "json"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- No API key needed
- GET https://api.ipify.org → plain text IP
- GET https://api.ipify.org?format=json → JSON
- IPv6: use api6.ipify.org
- Perfect for detecting client IP in server-side code