API Usage

Using https://www.ipv4ipv6.net/is ridiculously simple. You have three options. You can get your public IP directly (in plain text), you can get your public IP in JSON format, or you can get your public IP information in JSONP format (useful for Javascript developers).

 

Code samples 1

C#

var httpClient = new HttpClient();
var ip = await httpClient.GetStringAsync("https://www.ipv4ipv6.net/api/IpAddress/");
Console.WriteLine($"My public IP address is: {ip}");

output

My public IP address is:98.28.39.165

Code samples 2

using System;
using System.Net;

namespace Ipify.Examples {
    class Program {
        public static void Main (string[] args) {
            WebClient webClient = new WebClient();
            string publicIp = webClient.DownloadString("https://www.ipv4ipv6.net/api/IpAddress/");
            Console.WriteLine("My public IP Address is: {0}", publicIp);
        }
    }
}

 

 

API URLResponse TypeSample Output (IPv4)
   
https://www.ipv4ipv6.net/api/IpAddress/text98.207.254.136
https://www.ipv4ipv6.net/api/IpAddress/?format=jsonjson{"ip":"98.207.254.136"}

Comments


Comments are closed