.NET SDK · Feature

Errors, Rate Limits & Usage

Every method throws a typed exception on failure and the client never retries — you stay in control of back-off. It also exposes your current quota so you can throttle before you hit a limit, and aggregate usage for dashboards and alerts.

Trusted by thousands of businesses
Fast JSON API responses
Real-time validation
Simple integration, SDKs & examples
What it does

Predictable failures, no hidden retries

Network calls fail — keys expire, quotas run out, servers hiccup. The SDK turns each HTTP status into a specific exception type you can catch, and deliberately leaves retry policy to you, so a burst of failures can't silently multiply your request volume. When you do hit a rate limit, the exception tells you exactly when the quota resets.

Prerequisites

1

Catch the typed exceptions

Each exception derives from IpApiException and carries a StatusCode and Message. Catch the specific type you care about first.

using IpApiIo;
using IpApiIo.Exceptions;

try
{
    var info = await client.LookupAsync("8.8.8.8");
    Console.WriteLine(info.Ip);
}
catch (RateLimitException ex)
{
    Console.WriteLine($"quota hit — resets at {ex.Reset}");
}
catch (AuthenticationException)
{
    Console.WriteLine("check your API key");
}
catch (InvalidRequestException ex)
{
    Console.WriteLine($"bad request: {ex.Message}");
}
catch (ServerException)
{
    Console.WriteLine("ip-api.io is having trouble, try later");
}
catch (HttpRequestException ex)
{
    Console.WriteLine($"transport error: {ex.Message}");
}
Transport failures (DNS, connect, timeout) surface as the framework's HttpRequestException (or TaskCanceledException on timeout) — they are not an IpApiException.
2

Handle rate limits with RateLimitException

On HTTP 429 you get RateLimitException, carrying the x-ratelimit-* header values (-1 when a header is absent). Because the client never retries, Reset tells you when to.

catch (RateLimitException ex)
{
    Console.WriteLine(ex.Limit);     // your quota for the window
    Console.WriteLine(ex.Remaining); // requests left (0 here)
    Console.WriteLine(ex.Reset);     // Unix timestamp when quota renews
    // schedule a retry at ex.Reset instead of hammering the API
}
3

Check quota proactively with RateLimitAsync

Read your current limits without triggering a 429, so you can throttle in advance.

var rl = await client.RateLimitAsync();

Console.WriteLine(rl.PlanName);
Console.WriteLine($"{rl.IpApi.Remaining} / {rl.IpApi.Limit}");
Console.WriteLine($"{rl.EmailApi.UsagePercent:F1}% used");
4

Account usage with UsageSummaryAsync

Aggregate usage for the current period — handy for dashboards and internal alerts.

var usage = await client.UsageSummaryAsync();

Console.WriteLine($"{usage.TotalRequests} {usage.SuccessfulRequests}");
Console.WriteLine($"{usage.RateLimitedRequests} {usage.QuotaConsumed}");
Console.WriteLine($"{usage.PeriodStart} {usage.PeriodEnd}");
Reference

Exception taxonomy

ExceptionHTTP statusMeaning
AuthenticationException401, 403Missing or invalid API key
RateLimitException429Quota exhausted; carries Limit, Remaining, Reset
InvalidRequestException400, 404, 422Malformed input or unknown resource
ServerException5xxip-api.io server-side failure
IpApiExceptionotherBase type for all of the above (carries StatusCode, Message)
HttpRequestExceptionNetwork failure (framework exception, not an IpApiException)
FAQ

Frequently asked questions

How do I handle errors from the ip-api.io SDK in C#?

Every method throws on failure. Catch the typed exceptions, all derived from IpApiException: AuthenticationException (401/403), RateLimitException (429), InvalidRequestException (400/404/422), and ServerException (5xx). Network failures surface as HttpRequestException.

Does the SDK retry failed requests automatically?

No. The client never retries — you stay in control of back-off. On a 429, RateLimitException.Reset gives the Unix timestamp when your quota renews, so you can schedule a retry instead of hammering the API.

How do I check my remaining quota before hitting a limit?

Call await client.RateLimitAsync(). It returns PlanId, PlanName, and IpApi / EmailApi blocks with Limit, Remaining, Used and UsagePercent, plus IntervalSeconds and NextRenewalDate.

What does RateLimitException expose?

RateLimitException is parsed from the x-ratelimit-* response headers and carries Limit (quota for the window), Remaining (requests left), and Reset (Unix timestamp when quota renews). Headers absent? The value is -1.

Start building with the ip-api.io .NET SDK

Run dotnet add package IpApiIo, drop in your free API key, and ship in minutes — one async client for geolocation, fraud detection, and email validation.

Need support?

Explore how IP-API.io can enhance your security, provide robust bot protection, and improve IP geolocation accuracy for your applications.

Contact Support

Found a bug in the SDK?

The IpApiIo package is open source. Open an issue or pull request on GitHub and we'll take a look.

Open on GitHub