IPData 3.0.2
dotnet add package IPData --version 3.0.2
NuGet\Install-Package IPData -Version 3.0.2
<PackageReference Include="IPData" Version="3.0.2" />
<PackageVersion Include="IPData" Version="3.0.2" />
<PackageReference Include="IPData" />
paket add IPData --version 3.0.2
#r "nuget: IPData, 3.0.2"
#:package IPData@3.0.2
#addin nuget:?package=IPData&version=3.0.2
#tool nuget:?package=IPData&version=3.0.2
ipdata
v3 Breaking Changes — All public types have been renamed to follow .NET naming conventions for two-letter acronyms. See the Migration Guide for details.
ipdata.co is a fast, reliable and clean service that allows you to look up the location of an IP Address and other data.
Table of Content
- Install
- Lookup
- EU Endpoint
- Dependency Injection
- Migrating from v2 to v3
- Contributing
- Versioning
- License
Install
NuGet package install using package manager:
Install-Package IPData
NuGet package install using .NET CLI:
dotnet add package IPData
Lookup
All usage examples you can find on samples folder.
Basic
var client = new IPDataClient("API_KEY");
// Get IP data from my IP
var myIp = await client.Lookup();
Console.WriteLine($"Country name for {myIp.Ip} is {myIp.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 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}");
// Get multiple fields from IP
var geolocation = await client.Lookup("8.8.8.8", x => x.Latitude, x => x.Longitude);
Console.WriteLine($"Geolocation for 8.8.8.8 is lat: {geolocation.Latitude} long: {geolocation.Longitude}");
Bulk
From ipdata.co docs:
Note that bulk lookups are only available to paid users and are currently limited to a 100 at a time. Reach out to support if you need to lookup larger batches.
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
var client = new IPDataClient("API_KEY");
var carrierInfo = await client.Carrier("69.78.70.144");
Console.WriteLine($"Carrier name: {carrierInfo.Name}");
Company
var client = new IPDataClient("API_KEY");
var companyInfo = await client.Company("69.78.70.144");
Console.WriteLine($"Company name: {companyInfo.Name}");
ASN
var client = new IPDataClient("API_KEY");
var asnInfo = await client.Asn("69.78.70.144");
Console.WriteLine($"ASN name: {asnInfo.Name}");
Timezone
var client = new IPDataClient("API_KEY");
var timezoneInfo = await client.TimeZone("69.78.70.144");
Console.WriteLine($"TimeZone name: {timezoneInfo.Name}");
Currency
var client = new IPDataClient("API_KEY");
var currencyInfo = await client.Currency("69.78.70.144");
Console.WriteLine($"Currency name: {currencyInfo.Name}");
Threat
var client = new IPDataClient("API_KEY");
var threatInfo = await client.Threat("69.78.70.144");
Console.WriteLine($"Threat is Tor: {threatInfo.IsTor}");
EU Endpoint
To ensure your data stays in the EU, use the EU endpoint by passing a custom base URL:
var client = new IPDataClient("API_KEY", new Uri("https://eu-api.ipdata.co"));
var ipInfo = await client.Lookup("8.8.8.8");
Dependency Injection
If you're using ASP.NET Core, you can register IPDataClient with IHttpClientFactory to benefit from managed connection pooling and handler lifetimes:
// In Program.cs or Startup.cs
services.AddHttpClient("ipdata");
services.AddSingleton<IIPDataClient>(sp =>
{
var factory = sp.GetRequiredService<IHttpClientFactory>();
var httpClient = factory.CreateClient("ipdata");
return new IPDataClient("API_KEY", httpClient);
});
Then inject IIPDataClient wherever you need it:
public class MyService
{
private readonly IIPDataClient _ipDataClient;
public MyService(IIPDataClient ipDataClient)
{
_ipDataClient = ipDataClient;
}
public async Task<string> GetCountry(string ip)
{
var result = await _ipDataClient.Lookup(ip);
return result.CountryName;
}
}
Migrating from v2 to v3
v3 renames all public types to follow .NET naming conventions for two-letter acronyms. It also adds EU endpoint support and a Company lookup.
Renamed types
| v2 | v3 |
|---|---|
IpDataClient |
IPDataClient |
IIpDataClient |
IIPDataClient |
IpInfo |
IPLookupResult |
Namespace change
- using IpData;
- using IpData.Models;
+ using IPData;
+ using IPData.Models;
NuGet package
The package ID has changed from IpData to IPData:
dotnet remove package IpData
dotnet add package IPData
New features in v3
- EU endpoint — Pass a custom base URL to route requests through EU servers:
var client = new IPDataClient("API_KEY", new Uri("https://eu-api.ipdata.co")); - Company lookup — Fetch company info for an IP:
var companyInfo = await client.Company("8.8.8.8");
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 4.7.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on IPData:
| Repository | Stars |
|---|---|
|
thepirat000/spleeter-api
Audio separation API using Spleeter from Deezer
|
Release notes are at https://github.com/ipdata/dotnet/releases