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.

URLs to access service

Raw ip: https://omyip.com/raw

Json api: https://omyip.com/json

Json extended with geolocation: https://omyip.com/json?mode=extended

Json extended for given ip: https://omyip.com/json/[ip]/

How to use it in linux bash

#!/bin/bash
myip=$(curl -l -s "https://omyip.com/raw")
echo "$myip";

How to use it in Python

import requests

url = 'https://omyip.com/json'
response = requests.get(url)
public_ip = response.json()['ip']
print("Your public IP address is:", public_ip)

How to use it in JavaScript

fetch('https://omyip.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));

How to use it in 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://omyip.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

omyip.com is a user-friendly service that answers to 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.