IPMax 0.1.0

dotnet add package IPMax --version 0.1.0
                    
NuGet\Install-Package IPMax -Version 0.1.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="IPMax" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="IPMax" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="IPMax" />
                    
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 IPMax --version 0.1.0
                    
#r "nuget: IPMax, 0.1.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 IPMax@0.1.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=IPMax&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=IPMax&version=0.1.0
                    
Install as a Cake Tool

IPMax

.NET client for the IP-Max GeoIP and IP intelligence API. Targets .NET 8 and .NET 10, has no dependencies beyond the BCL, and is trimming and Native AOT friendly.

Install

dotnet add package IPMax

Quickstart

using IPMax;

using var ipmax = new IPMaxClient(Environment.GetEnvironmentVariable("IPMAX_API_KEY"));

var geo = await ipmax.LookupGeoIpAsync("8.8.8.8");
Console.WriteLine($"{geo.Geo.City} {geo.TimeZone?.Name}");

var intel = await ipmax.LookupIntelligenceAsync("8.8.8.8");
Console.WriteLine($"{intel.NetworkClass.Primary} {intel.Threat?.IsVpn}");

foreach (var ptr in intel.Intelligence.Ptr)
{
    if (ptr is PtrLocatedIntelligence located)
    {
        Console.WriteLine($"{located.Hostname} is in {located.Location.City}");
    }
}

var catalog = await ipmax.GetCatalogAsync();
var account = await ipmax.GetAccountAsync();

Every method accepts a CancellationToken, and lookups accept your own idempotency key:

await ipmax.LookupGeoIpAsync("8.8.8.8", idempotencyKey: "order-1042-geoip", cancellationToken: token);

To bring your own HttpClient (proxies, handlers, IHttpClientFactory), pass it first. The client never disposes an HttpClient it did not create.

var ipmax = new IPMaxClient(httpClient, apiKey, new IPMaxClientOptions { MaxRetries = 4 });

Configuration

Option Default Description
apiKey IPMAX_API_KEY env API key sent as a bearer token. GetCatalogAsync works without one.
BaseAddress https://api.ipm.ax API origin.
Timeout 10 s Per-attempt timeout.
MaxRetries 2 Retries on network errors, timeouts, 408, 429 and 5xx; honours Retry-After.
CacheSize 1024 Successful lookups kept in memory; 0 disables the cache.
CacheTtl 5 min Cache lifetime.
HttpClient a private instance Constructor overload for custom transports.

Each lookup carries a fresh UUID v4 Idempotency-Key that is reused on every retry, so a retried request is never billed twice. Cached lookups make no request and cost nothing; passing an explicit idempotencyKey skips the cache read. The client is thread-safe and meant to be reused.

String enums such as NetworkClass and RpkiStatus are open: unknown values from newer servers decode without error and keep their raw Value, so compare against the known members (NetworkClass.Hosting) rather than switching exhaustively.

Error handling

try
{
    await ipmax.LookupGeoIpAsync("192.0.2.1");
}
catch (IPMaxNotFoundException)
{
    Console.WriteLine("not in the database");
}
catch (IPMaxInsufficientBalanceException)
{
    Console.WriteLine("top up the geoip wallet");
}
catch (IPMaxRateLimitException error)
{
    Console.WriteLine($"retry in {error.RetryAfter}");
}
catch (IPMaxApiException error)
{
    Console.WriteLine($"{error.StatusCode} {error.Code} {error.Message} {error.RequestId}");
}
Exception When
IPMaxException Base class of every exception below
IPMaxApiException Any non-2xx response
IPMaxInvalidRequestException 400, 413, 415
IPMaxAuthenticationException 401
IPMaxInsufficientBalanceException 402
IPMaxNotFoundException 404
IPMaxConflictException 409
IPMaxRateLimitException 429
IPMaxServerException 5xx
IPMaxConnectionException The request never got a response
IPMaxTimeoutException An attempt exceeded Timeout

IPMaxApiException exposes StatusCode, Code (an ErrorCode such as ErrorCode.IpNotFound), Message, RequestId, Retryable and RetryAfter. Cancelling your own token throws OperationCanceledException as usual.

License

Apache-2.0

Product Compatible and additional computed target framework versions.
.NET 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 is compatible.  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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

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
0.1.0 107 10/3/2026