IPinfo 2.0.2
See the version list below for details.
dotnet add package IPinfo --version 2.0.2
NuGet\Install-Package IPinfo -Version 2.0.2
<PackageReference Include="IPinfo" Version="2.0.2" />
paket add IPinfo --version 2.0.2
#r "nuget: IPinfo, 2.0.2"
// Install IPinfo as a Cake Addin
#addin nuget:?package=IPinfo&version=2.0.2
// Install IPinfo as a Cake Tool
#tool nuget:?package=IPinfo&version=2.0.2
<a href="https://ipinfo.io/"><img src="https://raw.githubusercontent.com/ipinfo/csharp/main/src/IPinfo/icon.png" alt="IPinfo" width="24" /></a> IPinfo C# .NET SDK
This is the official C# .NET SDK for the IPinfo.io IP address API, allowing you to lookup your own IP address, or get any of the following details for other IP addresses:
- 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)
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
Installation
This package can be installed from NuGet.
Install using Package Manager
Install-Package IPinfo
Install using the dotnet CLI
dotnet add package IPinfo
Install with NuGet.exe
nuget install IPinfo
Quick Start
// namespace
using IPinfo;
using IPinfo.Models;
// initializing IPinfo client
string token = "MY_TOKEN";
IPinfoClient client = new IPinfoClient.Builder()
.AccessToken(token)
.Build();
Usage
// making API call
string ip = "216.239.36.21";
IPResponse ipResponse = await client.IPApi.GetDetailsAsync(ip);
// accessing location details from response
Console.WriteLine($"IPResponse.IP: {ipResponse.IP}");
Console.WriteLine($"IPResponse.City: {ipResponse.City}");
Console.WriteLine($"IPResponse.Company.Name: {ipResponse.Company.Name}");
Console.WriteLine($"IPResponse.Country: {ipResponse.Country}");
Console.WriteLine($"IPResponse.CountryName: {ipResponse.CountryName}");
Synchronous
// making synchronous API call
string ip = "216.239.36.21";
IPResponse ipResponse = client.IPApi.GetDetails(ip);
Country Name Lookup
ipResponse.CountryName
will return the country name, whereas ipResponse.Country
can be used to fetch the country code.
Additionally ipResponse.IsEU
will return true
if the country is a member of the European Union (EU).
string ip = "1.1.1.1";
// making API call
IPResponse ipResponse = await client.IPApi.GetDetailsAsync(ip);
// country code, e.g. 'US'
Console.WriteLine($"IPResponse.Country: {ipResponse.Country}");
// country name, e.g. 'United States'
Console.WriteLine($"IPResponse.CountryName: {ipResponse.CountryName}");
// whether part of the EU, e.g. false
Console.WriteLine($"IPResponse.isEU: {ipResponse.isEU}");
Caching
In-memory caching of data is provided by default. Custom implementation of the cache can also be provided by implementing the ICache
interface.
Modifying cache options
// namespace
using IPinfo;
using IPinfo.Cache;
long cacheEntryTimeToLiveInSeconds = 2*60*60*24; // 2 days
int cacheSizeMbs = 2;
IPinfoClient client = new IPinfoClient.Builder()
.AccessToken(token) // pass your token string
.Cache(new CacheWrapper(cacheConfig => cacheConfig
.CacheMaxMbs(cacheSizeMbs) // pass cache size in mbs
.CacheTtl(cacheEntryTimeToLiveInSeconds))) // pass time to live in seconds for cache entry
.Build();
Bogon Filtering
The Bogon
property of the IPResponse
object can be used to check if an IP address is a bogon.
// namespace
using IPinfo;
using IPinfo.Models;
string ip = "127.0.0.1";
IPResponse ipResponse = await client.IPApi.GetDetailsAsync(ip);
if (ipResponse.Bogon)
{
Console.WriteLine($"{ipResponse.IP} is a bogon.");
}
else
{
// display ip details
Console.WriteLine($"IPResponse.IP: {ipResponse.IP}");
Console.WriteLine($"IPResponse.City: {ipResponse.City}");
Console.WriteLine($"IPResponse.CountryName: {ipResponse.CountryName}");
}
Samples
Sample codes are also available.
Other Libraries
There are official IPinfo client libraries available for many languages including PHP, Go, Java, Ruby, and many popular frameworks such as Django, Rails and Laravel. There are also many third party libraries and integrations available for our API.
About IPinfo
Founded in 2013, IPinfo prides itself on being the most reliable, accurate, and in-depth source of IP address data available anywhere. We process terabytes of data to produce our custom IP geolocation, company, carrier, VPN detection, hosted domains, and IP type data sets. Our API handles over 40 billion requests a month for 100,000 businesses and developers.
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. |
.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.Runtime.Caching (>= 6.0.0)
- System.Text.Json (>= 6.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on IPinfo:
Repository | Stars |
---|---|
codesiddhant/Jasmin-Ransomware
Jasmin Ransomware is an advanced red team tool (WannaCry Clone) used for simulating real ransomware attacks. Jasmin helps security researchers to overcome the risk of external attacks.
|
|
mysteryx93/HanumanInstituteApps
432Hz Player, 432Hz Batch Converter, Powerliminals Player, Yang YouTube Downloader
|
Version | Downloads | Last updated |
---|---|---|
3.0.0 | 37,869 | 12/7/2023 |
2.1.0 | 111,287 | 1/25/2023 |
2.0.2 | 42,081 | 9/1/2022 |
2.0.1 | 7,480 | 7/15/2022 |
2.0.0 | 3,056 | 6/9/2022 |
1.1.14 | 24,561 | 12/20/2021 |
1.1.13 | 14,516 | 11/10/2021 |
1.1.12 | 645 | 11/5/2021 |
1.1.11 | 1,156 | 10/27/2021 |
1.1.9 | 5,885 | 7/6/2021 |
1.1.8 | 699 | 7/6/2021 |
1.1.4 | 685 | 7/6/2021 |
1.1.3 | 648 | 7/6/2021 |
1.1.1 | 720 | 7/6/2021 |
1.0.5.4 | 783 | 7/5/2021 |
1.0.5.3 | 648 | 7/5/2021 |
1.0.5.2 | 5,368 | 3/25/2021 |
1.0.5.1 | 5,890 | 9/5/2020 |
1.0.5 | 1,089 | 8/30/2020 |
1.0.4.2 | 898 | 8/30/2020 |
1.0.4.1 | 905 | 8/30/2020 |
1.0.4 | 905 | 8/30/2020 |
1.0.3 | 904 | 8/30/2020 |
1.0.2 | 914 | 8/30/2020 |
1.0.1 | 851 | 8/10/2020 |
1.0.0 | 895 | 8/9/2020 |
1.0.0-beta.4 | 269 | 8/9/2020 |
1.0.0-beta.3 | 293 | 8/9/2020 |
1.0.0-beta.2 | 318 | 8/9/2020 |
1.0.0-beta.1 | 557 | 8/9/2020 |
Added IsEU property to check if the country is a member of the European Union (EU).