.Net

Contributed by Alex Khil - https://github.com/alexkhil. View the package on Github - https://github.com/alexkhil/IpData.

Installation

NuGet package install using package manager:

Install-Package IpData -Version 1.0.0

NuGet package install using .NET CLI:

dotnet add package IpData --version 1.0.0

Basic Usage

var client = new IpDataClient("API_KEY");
// Get ip data from my ip
var myIpInfo = await client.Lookup();
Console.WriteLine($"Country name for {myIpInfo.Ip} is {myIpInfo.CountryName}");
// Get localized ip data from my ip
var myIpInfoLocalized = await client.Lookup(CultureInfo.GetCultureInfo("zh-CN"));
Console.WriteLine($"Localized country name for {myIpInfoLocalized.Ip} is {myIpInfoLocalized.CountryName}");
// Get ip data from ip
var ipInfo = await client.Lookup("8.8.8.8");
Console.WriteLine($"Country name for {ipInfo.Ip} is {ipInfo.CountryName}");
// Get localized ip data from ip
var ipInfoLocalized = await client.Lookup("8.8.8.8", CultureInfo.GetCultureInfo("zh-CN"));
Console.WriteLine($"Localized country name for {myIpInfoLocalized.Ip} is {ipInfoLocalized.CountryName}");
// Get single field from ip
var countryName = await client.Lookup("8.8.8.8", x => x.CountryName);
Console.WriteLine($"Country name for 8.8.8.8 is {countryName}");

Bulk Lookup

var client = new IpDataClient("API_KEY");
var ipInfoList = await client.Lookup(new string[] { "1.1.1.1", "2.2.2.2", "3.3.3.3" });
foreach (var ipInfo in ipInfoList)
{
Console.WriteLine($"Country name for {ipInfo.Ip} is {ipInfo.CountryName}");
}

Carrier Lookup

var client = new IpDataClient("API_KEY");
var carrierInfo = await client.Carrier("69.78.70.144");
Console.WriteLine($"Carrier name: {carrierInfo.Name}");