[IP to Mobile Carrier] Get mobile carrier information from a phone’s IP address using the C# language
If you are using the C# programming language and want to look up whether or an IP address is a mobile carrier IP address and get the associated information, you can use our IP to Mobile Carrier API service. To get started:
Step 1: Get your access token.
Sign up for the appropriate tier and copy your IPinfo access token from your dashboard.
Step 2: Install the IPinfo C# library
Visit our official open-source IPinfo C# library GitHub repo and follow the instructions to install the library.
Step 3: IPinfo C# library ⇒ IP to Mobile Carrier
After importing and initializing the IPinfo package, you will need to call the following methods on the IPResponse
class variable:
Code | Description |
---|---|
ipResponse.Carrier.Name | Name of the mobile carrier company associated with the IP address |
ipResponse.Carrier.Mcc | Mobile Country Code (MCC) |
ipResponse.Carrier.Mnc | Mobile Network Code (MNC) |
Starter code template
//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 = "174.245.67.12"; IPResponse ipResponse = await client.IPApi.GetDetailsAsync(ip); //////////////////////////// // IP to Carrier Insights // //////////////////////////// Console.WriteLine($"Mobile Carrier Name: {ipResponse.Carrier.Name}"); Console.WriteLine($"Mobile Country Code: {ipResponse.Carrier.Mcc}"); Console.WriteLine($"Mobile Network Code: {ipResponse.Carrier.Mnc}"); } } } <br>
Result
Mobile Carrier Name: Verizon Mobile Country Code: 311 Mobile Network Code: 480<br>
Besides the API service, IPinfo’s IP to Mobile Carrier data is also available as a database: IP to mobile carrier database download.
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
If you have any questions, please reach out to us.