.NET SDK: project reference and async lookup
.NET 8. Add the extracted Origooo.csproj as a project reference and build your solution. The source archive is not a NuGet publication.
using Origooo;
var client = new OrigoooClient(new HttpClient(),
Environment.GetEnvironmentVariable("ORIGOOO_API_KEY")!,
new Uri("https://orig.ooo"),
timeout: TimeSpan.FromSeconds(2), ttl: TimeSpan.FromMinutes(5));
try {
var result = await client.LookupAsync("8.8.8.8");
string? country = result.CountryCode;
} catch (OrigoooException error) {
int status = error.Status;
// Apply your fallback.
}Also handle cancellation, HttpRequestException and malformed JSON. Reuse a managed HttpClient. Location has Ip, CountryCode, City and SourceId. CountryMiddleware accepts a CountryPolicy; verify compilation/wiring in your .NET application.
Coverage, caching and failures
The source SDKs expose single-IP lookup and country-policy helpers. Use direct HTTP for batch, ASN, comparisons and metadata. A 404 becomes an empty country result. A 429 surfaces as an exception; handle it with bounded backoff in your application. Local SDK cache hits make no HTTP request. API-side cache hits remain billable.
Set the API origin explicitly to https://orig.ooo. Resolve a visitor IP using your configured trusted-proxy rules; a backend /v1/ip/me request identifies the backend server.
Apply a country policy
The following code belongs before protected content. It uses the actual client/policy interfaces in the downloadable SDK. The full guide includes installation assumptions, proxy handling and unknown-country behaviour.
using Origooo;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton(new OrigoooClient(new HttpClient(),
Environment.GetEnvironmentVariable("ORIGOOO_API_KEY")!,
new Uri("https://orig.ooo")));
builder.Services.AddSingleton(new CountryPolicy(
blocked: new[] { "US", "GB" }, unknown: "deny"));
var app = builder.Build();
// If needed, configure Forwarded Headers with explicit trusted proxies
// before this middleware. Never trust arbitrary forwarded headers.
app.UseMiddleware<CountryMiddleware>();
app.MapGet("/protected", () => "Allowed content");
app.Run();