MyIpFoo 1.0.0

dotnet add package MyIpFoo --version 1.0.0
                    
NuGet\Install-Package MyIpFoo -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MyIpFoo" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MyIpFoo" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MyIpFoo" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MyIpFoo --version 1.0.0
                    
#r "nuget: MyIpFoo, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MyIpFoo@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MyIpFoo&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MyIpFoo&version=1.0.0
                    
Install as a Cake Tool

MyIpFoo

Official .NET client for myip.foo - a free, privacy-focused IP lookup API.

NuGet version License: MIT

Features

  • Async/await support
  • Full model types with records
  • Dual-stack IPv4/IPv6 support
  • Connection type detection
  • No API key required
  • .NET 6.0+ and .NET 8.0+

Installation

dotnet add package MyIpFoo

Or via Package Manager:

Install-Package MyIpFoo

Quick Start

using MyIpFoo;

// Create client (uses default HttpClient)
using var client = new MyIpClient();

// Get plain IP
var ip = await client.GetIpAsync();
Console.WriteLine(ip); // "203.0.113.42"

// Get full data with geolocation
var data = await client.GetIpDataAsync();
Console.WriteLine(data.Ip);                  // "203.0.113.42"
Console.WriteLine(data.Location.City);       // "Amsterdam"
Console.WriteLine(data.Location.Country);    // "NL"
Console.WriteLine(data.Network.Isp);         // "KPN B.V."
Console.WriteLine(data.ConnectionType);      // "residential"

// Get both IPv4 and IPv6
var dualStack = await client.GetDualStackAsync();
Console.WriteLine(dualStack.IPv4); // "203.0.113.42"
Console.WriteLine(dualStack.IPv6); // "2001:db8::1" or null

Dependency Injection

Use with IHttpClientFactory:

// In Startup.cs or Program.cs
services.AddHttpClient<MyIpClient>();

// In your service
public class MyService
{
    private readonly MyIpClient _myIpClient;

    public MyService(MyIpClient myIpClient)
    {
        _myIpClient = myIpClient;
    }

    public async Task<string> GetCurrentIp()
    {
        return await _myIpClient.GetIpAsync();
    }
}

API Reference

Methods

GetIpAsync() -> Task<string>

Returns your IP address as plain text.

GetIpDataAsync() -> Task<IpData>

Returns full IP data including geolocation.

GetDualStackAsync(int timeout = 5) -> Task<DualStackData>

Returns both IPv4 and IPv6 addresses.

GetConnectionTypeAsync() -> Task<ConnectionTypeData>

Detects if connection is residential, VPN, or datacenter.

GetHeadersAsync() -> Task<Dictionary<string, string>>

Returns all HTTP headers as seen by the server.

GetUserAgentAsync() -> Task<string>

Returns your user agent string.

Models

public record IpData
{
    public string Ip { get; init; }
    public string Type { get; init; }  // "IPv4" or "IPv6"
    public string? Hostname { get; init; }
    public string? ConnectionType { get; init; }  // "residential", "vpn", "datacenter", "tor"
    public Location Location { get; init; }
    public Network Network { get; init; }
    public CloudflareInfo Cloudflare { get; init; }
}

public record DualStackData
{
    public string? IPv4 { get; init; }
    public string? IPv6 { get; init; }
}

public record ConnectionTypeData
{
    public string Ip { get; init; }
    public string Type { get; init; }  // "residential", "vpn", "datacenter", "unknown"
}

Dual-Stack Endpoints

The GetDualStackAsync() method uses dedicated subdomains:

  • ipv4.myip.foo/ip - Returns IPv4 only (A record)
  • ipv6.myip.foo/ip - Returns IPv6 only (AAAA record)

Privacy

myip.foo does not log IP addresses or use cookies. See Privacy Policy.

License

MIT License - see LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 232 11/24/2025