H.IpInfo
1.0.1
dotnet add package H.IpInfo --version 1.0.1
NuGet\Install-Package H.IpInfo -Version 1.0.1
<PackageReference Include="H.IpInfo" Version="1.0.1" />
paket add H.IpInfo --version 1.0.1
#r "nuget: H.IpInfo, 1.0.1"
// Install H.IpInfo as a Cake Addin #addin nuget:?package=H.IpInfo&version=1.0.1 // Install H.IpInfo as a Cake Tool #tool nuget:?package=H.IpInfo&version=1.0.1
Unofficial generated IPinfo C# Client Library based on OpenAPI spec
This is the unofficial C# client library for the IPinfo.io IP address API, allowing you to lookup your own IP address, or get any of the following details for an IP:
- IP geolocation / geoIP data (city, region, country, postal code, latitude and longitude)
- ASN details (ISP or network operator, associated domain name, and type, such as business, hosting or company)
- Firmographics data (the name and domain of the business that uses the IP address)
- Carrier information (the name of the mobile carrier and MNC and MCC for that carrier if the IP is used exclusively for mobile traffic)
Pros compared to the new official version:
- Almost completely generated based on the OpenAPI specification, which eliminates errors when writing boiler plate code
- The OpenAPI specification can be used to generate a client for your needs, for any language
- All APIs are implemented
- There is no synchronous API here which is prone to Task.Wait() errors
Cons:
- No built-in caching
Getting Started
You'll need an IPinfo API access token, which you can get by singing up for a free account at https://ipinfo.io/signup.
The free plan is limited to 50,000 requests per month, and doesn't include some of the data fields such as IP type and company data. To enable all the data fields and additional request volumes see https://ipinfo.io/pricing
Nuget
Install-Package H.IpInfo
Usage
using IpInfo;
using var client = new HttpClient();
// Some methods work without a token, for this case there is a constructor without a token.
var api = new IpInfoApi("your-token", client);
var response = await api.GetCurrentInformationAsync();
Console.WriteLine($"City: {response.City}");
Batch API
// WARNING: Token required.
var dictionary = await api.GetInformationByIpsAsync(new[]
{
"8.8.8.8",
"8.8.4.4",
}, cancellationToken);
foreach (var pair in dictionary)
{
Console.WriteLine($"{pair.Key} City: {pair.Value.City}");
}
// 8.8.4.4 City: Amstelveen
// 8.8.8.8 City: Mountain View
// WARNING: Token required.
var dictionary = await api.BatchAsync(new []
{
"8.8.4.4/city",
"8.8.8.8/city",
}, cancellationToken);
foreach (var pair in dictionary)
{
Console.WriteLine($"{pair.Key}: {pair.Value}");
}
// 8.8.4.4: Amstelveen
// 8.8.8.8: Mountain View
Privacy Detection API
// WARNING: Token required. The token must have at least permissions of the Business Plan.
// Otherwise, you'll get a response with an HTTP 403 status code.
var privacy = await api.GetPrivacyInformationByIpAsync("8.8.8.8", cancellationToken);
Console.WriteLine($"Vpn: {privacy.Vpn}");
Console.WriteLine($"Proxy: {privacy.Proxy}");
Console.WriteLine($"Tor: {privacy.Tor}");
Console.WriteLine($"Hosting: {privacy.Hosting}");
// Vpn: False
// Proxy: False
// Tor: False
// Hosting: False
Contacts
Other Libraries
There are official IPinfo client libraries available for many languages including PHP, Go, Java, Ruby, C# and many popular frameworks such as Django, Rails and Laravel. There are also many third party libraries and integrations available for our API.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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. |
.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 is compatible. 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. |
-
.NETFramework 4.6.1
- System.Text.Json (>= 6.0.5)
-
.NETStandard 2.0
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 6.0.5)
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.1 | 1,001 | 8/1/2022 |
⭐ Last 10 features:
Merged mark `service` field as required
Added optional PrivacyResponse.Service value.
add-relay-field
Added README to NuGet package.
To net6 and C# 10.
Added symbols.
Added AsnResponse.type 'inactive' value.
city and country is not required more. Added bogon property.
Updated to use H.NSwag.Generator instead manual generation.
Updated NuGet packages.
🐞 Last 10 bug fixes:
To H.NSwag.Generator 13.15.10 to fix some issues.
Fixed GetInformationByIpsAsync nullable warning.
Added null checks for ctor.
Fixed missing ConfigureAwait(false) in GetInformationByIpsAsync.
Removed timezone and loc from required properties.
Removed timezone and loc from required properties.
Fixed #10.
Fixed #10.
Commented Run tests in dotnet.yml(Test token is not valid).
Fixed dotnet.yml.