Coder Social home page Coder Social logo

g-u-r-k-a-n / csharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ipinfo/csharp-old

0.0 0.0 0.0 266 KB

Official C# Library for IPinfo API (IP geolocation and other types of IP data)

Home Page: http://ipinfo.io

License: Apache License 2.0

C# 100.00%

csharp's Introduction

IPinfo IPinfo C# Client Library

Language License Requirements Requirements Build Status

This is the official 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)

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

NuGet

Install-Package IpInfo

Usage

using IpInfo;

using var client = new HttpClient();
var api = new IpInfoApi("your-token", client); // Some methods work without a token, for this case there is a constructor without a token.

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.
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

Live Example

C# .NET Fiddle - https://dotnetfiddle.net/i5MmNp
VB.NET .NET Fiddle - https://dotnetfiddle.net/EUszSY

Contacts

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.

image

csharp's People

Contributors

havendv avatar st-polina avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.