# \[C# / .NET\] Lookup ASN and Company information from an IP address using the C# programming language

**URL:** <https://community.ipinfo.io/t/c-net-lookup-asn-and-company-information-from-an-ip-address-using-the-c-programming-language/42>\
**Category:** Official Libraries\
**Tags:** api, csharp, dotnet, asn, ip-company\
**Created:** [March 27, 2023, 10:58am UTC](https://community.ipinfo.io/t/c-net-lookup-asn-and-company-information-from-an-ip-address-using-the-c-programming-language/42 "2023-03-27T10:58:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abdullah](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.ipinfo.io/abdullah/32/4973_2.png) [@Abdullah](https://community.ipinfo.io/u/Abdullah)\
**Post date:** [March 27, 2023, 10:58am UTC](https://community.ipinfo.io/t/c-net-lookup-asn-and-company-information-from-an-ip-address-using-the-c-programming-language/42/1 "2023-03-27T10:58:14Z")

</div>

If you are using the C# programming language and want to look up the ASN and company information of an IP address, you can use our [ASN API](https://ipinfo.io/products/asn-api) and [IP to Company Service](https://ipinfo.io/products/ip-company-api). To get started:

**Step 1: Get your access token.**

Sign up for the [appropriate tier](https://ipinfo.io/pricing) and copy your IPinfo access token from [your dashboard](https://ipinfo.io/account/token).

**Step 2: Install the IPinfo C# library**

Visit our official open-source [IPinfo C# library GitHub repo](https://github.com/ipinfo/csharp) and follow the instructions to [install the library](https://github.com/ipinfo/csharp#installation).

**Step 3: IPinfo C# library ⇒ IP to Company and ASN**

After importing and initializing the IPinfo package, you will need to call the following methods on the `IPResponse` class variable:

IP to ASN information:

| Code | Description |
| --- | --- |
| ipResponse.Asn.Asn | ASN of the IP address |
| `ipResponse.Asn.Domain` | Domain of the ASN |
| `ipResponse.Asn.Name` | Organization name of the ASN |
| `ipResponse.Asn.Route` | IP address route or network range of the ASN |
| `ipResponse.Asn.Type` | Type of ASN |

IP to company information:

| Code | Description |
| --- | --- |
| `ipResponse.Company.Name` | Name of the company associated with the IP address |
| `ipResponse.Company.Domain` | Domain / Website of the company |
| `ipResponse.Company.Type` | Type of company/organization |

**Starter code template**

```csharp
//namespace
using IPinfo;
using IPinfo.Models;

namespace IPinfoApp {      
    // Class declaration
    class IPlookup {
          
        // Main Method
        static async Task Main(string[] args) {
            
            ////////////////////////////////
            // initializing IPinfo client // 
            ////////////////////////////////

            // Get your IPinfo access token from: ipinfo.io/account/token
            string token = "YOUR_TOKEN";
            IPinfoClient client = new IPinfoClient.Builder()
                .AccessToken(token)
                .Build();

            // making the API call
            string ip = "19.12.136.0";
            IPResponse ipResponse = await client.IPApi.GetDetailsAsync(ip);

            ////////////////////////////
            // ASN / Company Insights //
            ////////////////////////////
            
            // ASN Information
            Console.WriteLine($"ASN: {ipResponse.Asn.Asn}");
            Console.WriteLine($"ASN Domain: {ipResponse.Asn.Domain}");
            Console.WriteLine($"ASN Name: {ipResponse.Asn.Name}");
            Console.WriteLine($"ASN Route: {ipResponse.Asn.Route}");
            Console.WriteLine($"ASN Type: {ipResponse.Asn.Type}");

            // Comapny Information
            Console.WriteLine($"Comany Name: {ipResponse.Company.Name}");
            Console.WriteLine($"Comany Domain: {ipResponse.Company.Domain}");
            Console.WriteLine($"Comany Type: {ipResponse.Company.Type}");
        }
    }
}

```

**Result**

```auto
ASN: AS3389
ASN Domain: ford.com
ASN Name: Ford Motor Company
ASN Route: 19.12.136.0/21
ASN Type: business

Comany Name: Ford Motor Company
Comany Domain: ford.com
Comany Type: business

```

Besides the API service, IPinfo’s IP to ASN data and IP to Company data is also available as a database: [ASN database download](https://ipinfo.io/products/asn-database) & [IP to Company database download](https://ipinfo.io/products/ip-company-database).

To learn more about using the C# language and .NET framework with IPinfo, please check out our article: **[First steps with C#/.NET & IPinfo’s API and Database](https://ipinfo.io/blog/ip-geolocation-c-sharp/)**

### Code Snippet Generator

> **Code Snippet Generator (Click Me)**
>
> 1. Pass the variables to the form
> 2. Copy the code snippet
> 
> ### Form
> 
> ### Code Snippet
> 
> ```csharp
> //namespace
> using IPinfo;
> using IPinfo.Models;
> 
> namespace IPinfoApp {      
> // Class declaration
> class IPlookup {
>           
> // Main Method
> static async Task Main(string[] args) {
>             
> ////////////////////////////////
> // initializing IPinfo client // 
> ////////////////////////////////
> 
> // Get your IPinfo access token from: ipinfo.io/account/token
> string token = "=YOUR_TOKEN=";
> IPinfoClient client = new IPinfoClient.Builder()
> .AccessToken(token)
> .Build();
> 
> // making the API call
> string ip = "=IP_ADDRESS=";
> IPResponse ipResponse = await client.IPApi.GetDetailsAsync(ip);
> 
> ////////////////////////////
> // ASN / Company Insights //
> ////////////////////////////
>             
> // ASN Information
> Console.WriteLine($"ASN: {ipResponse.Asn.Asn}");
> Console.WriteLine($"ASN Domain: {ipResponse.Asn.Domain}");
> Console.WriteLine($"ASN Name: {ipResponse.Asn.Name}");
> Console.WriteLine($"ASN Route: {ipResponse.Asn.Route}");
> Console.WriteLine($"ASN Type: {ipResponse.Asn.Type}");
> 
> // Comapny Information
> Console.WriteLine($"Comany Name: {ipResponse.Company.Name}");
> Console.WriteLine($"Comany Domain: {ipResponse.Company.Domain}");
> Console.WriteLine($"Comany Type: {ipResponse.Company.Type}");
> }
> }
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![Abdullah](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.ipinfo.io/abdullah/32/4973_2.png) [@Abdullah](https://community.ipinfo.io/u/Abdullah)\
**Post date:** [April 4, 2023, 10:55am UTC](https://community.ipinfo.io/t/c-net-lookup-asn-and-company-information-from-an-ip-address-using-the-c-programming-language/42/2 "2023-04-04T10:55:56Z")

</div>


