How to get my public IP programmatically?
Introducing our innovative service tailored to meet your networking needs - the Public IP Address Provider. Designed to effortlessly furnish you with the critical information of your public IP address, our service offers seamless integration across multiple programming languages, ensuring accessibility and ease of use for developers and users alike.
With the ever-evolving landscape of technology, knowing your public IP address is essential for various applications, from network troubleshooting to configuring remote access. Our service simplifies this process, allowing you to retrieve your public IP address promptly and reliably.
Accessible through a diverse array of programming languages, including Python, JavaScript, Java, and more, our API enables seamless integration into your existing projects and systems. Whether you're developing web applications, network monitoring tools, or simply need to obtain your public IP address programmatically, our service offers the flexibility and versatility to accommodate your requirements.
API Endpoints
Raw IP: https://myip1.com/raw
JSON API: https://myip1.com/json
JSON with geolocation: https://myip1.com/json?mode=extended
JSON for specific IP: https://myip1.com/json/[ip]/
Rate limit notice: Please cache results. Requests over 300 RPM will receive a warning, and repeated overage can trigger a 5-minute ban.
Linux Bash
#!/bin/bash myip=$(curl -s "https://myip1.com/raw") echo "$myip"
Python
import requests
url = 'https://myip1.com/json'
response = requests.get(url)
public_ip = response.json()['ip']
print("Your public IP address is:", public_ip)
JavaScript
fetch('https://myip1.com/json')
.then(response => response.json())
.then(data => console.log("Your public IP address is:", data.ip))
.catch(error => console.error("Error fetching IP:", error));
Java
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
try {
URL url = new URL("https://myip1.com/raw");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.connect();
Scanner scanner = new Scanner(url.openStream());
String response = scanner.useDelimiter("\\A").next();
scanner.close();
System.out.println("Your public IP address is: " + response);
} catch (Exception e) {
e.printStackTrace();
}
}
}
About Service
myip1.com is a user-friendly service that answers the question 'what is my ip?' and instantly provides users with their public IP address. With a simple interface, it eliminates the need for technical know-how, making it accessible for various purposes such as troubleshooting network issues or setting up remote access.