Skip to content
forked from ipdata/dotnet

C#(CSharp) library to gather information for an ip using ipdata.co

License

Notifications You must be signed in to change notification settings

drozhkov/IpData

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ip Data Logo

IpData License: MIT IpData

ipdata.co is a fast, reliable and clean service that allows you to look up the location of an IP Address and other data.

Branch Platform Status Coverage
Master Linux\Windows\macOS Build Status Coverage Status
Develop Linux\Windows\macOS Build Status Coverage Status

Table of Content

Installing

NuGet package install using package manager:

Install-Package IpData -Version 1.1.0

NuGet package install using .NET CLI:

dotnet add package IpData --version 1.1.0

Usage

All usage examples you can find on samples folder.

Basic Lookup

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

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 Lookup

var client = new IpDataClient("API_KEY");

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

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

About

C#(CSharp) library to gather information for an ip using ipdata.co

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 86.7%
  • PowerShell 9.5%
  • Shell 3.8%