To use an IP location finding API, you need to send a GET request to the API's endpoint. Here's how you can do it using C#:
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
public class Program
{
public static async Task Main()
{
var ip = "IP_Address"; // Replace with the IP Address you want to lookup
var token = "YOUR_API_KEY"; // Replace with your actual API key
using (HttpClient client = new HttpClient())
{
HttpResponseMessage response = await client.GetAsync($"https://api.findip.net/{ip}/?token={token}");
if(response.IsSuccessStatusCode)
{
var jsonString = await response.Content.ReadAsStringAsync();
JObject data = JObject.Parse(jsonString);
Console.WriteLine($"City Name: {data["city"]["names"]["en"]}");
Console.WriteLine($"Continent Code: {data["continent"]["code"]}");
Console.WriteLine($"Country Name: {data["country"]["names"]["en"]}");
Console.WriteLine($"Latitude: {data["location"]["latitude"]}");
Console.WriteLine($"Longitude: {data["location"]["longitude"]}");
Console.WriteLine($"Time Zone: {data["location"]["time_zone"]}");
Console.WriteLine($"Weather Code: {data["location"]["weather_code"]}");
Console.WriteLine($"Autonomous System Number: {data["traits"]["autonomous_system_number"]}");
Console.WriteLine($"Autonomous System Organization: {data["traits"]["autonomous_system_organization"]}");
Console.WriteLine($"Connection Type: {data["traits"]["connection_type"]}");
Console.WriteLine($"ISP: {data["traits"]["isp"]}");
Console.WriteLine($"User Type: {data["traits"]["user_type"]}");
var subdivisions = data["subdivisions"];
foreach(var subdivision in subdivisions)
{
if(subdivision["names"]["en"] != null)
Console.WriteLine($"Subdivision Name: {subdivision["names"]["en"]}");
}
}
}
}
}
Remember to replace 'IP_Address' and 'YOUR_API_KEY' with the actual IP address you want to verify and your actual API key. Also, ensure to add the Newtonsoft.Json package to your project which you can add via NuGet in Visual Studio.