AlphaQuantum.WebFilteringDatabase 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AlphaQuantum.WebFilteringDatabase --version 1.0.0
                    
NuGet\Install-Package AlphaQuantum.WebFilteringDatabase -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="AlphaQuantum.WebFilteringDatabase" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AlphaQuantum.WebFilteringDatabase" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AlphaQuantum.WebFilteringDatabase" />
                    
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 AlphaQuantum.WebFilteringDatabase --version 1.0.0
                    
#r "nuget: AlphaQuantum.WebFilteringDatabase, 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 AlphaQuantum.WebFilteringDatabase@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=AlphaQuantum.WebFilteringDatabase&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AlphaQuantum.WebFilteringDatabase&version=1.0.0
                    
Install as a Cake Tool

AlphaQuantum.WebFilteringDatabase

Classify a domain into a web filtering category from C#. Filtering proxies, DNS services, parental-control apps and MSP portals built on .NET use this client to label domains their local lists do not cover, using domain filtering categories for .NET proxies and other enforcement points.

dotnet add package AlphaQuantum.WebFilteringDatabase

Basic use

using AlphaQuantum.WebFilteringDatabase;

var wf = new WebFilteringDatabaseClient(Environment.GetEnvironmentVariable("AQ_API_KEY")!);
var r = await wf.ClassifyAsync("some-new-domain.example");

The result is a Dictionary<string, JsonElement> holding the service's reply unchanged. Its main value is the filtering category and a confidence score. The full list of fields is in the API reference on the product site.

The file and the API work together

The licensed database is a download you load into memory: fast, local, and fixed until the next release. This client covers what arrives in between. In practice, the file answers the vast majority of lookups and the API handles a small, steady trickle of new hosts. Build for that shape: local first, API for misses, and remember every answer.

Middleware for an ASP.NET Core filtering proxy

If your proxy runs on ASP.NET Core (for example with YARP), a middleware can decide before a request is forwarded. The expensive classification must never hold up the request itself:

public sealed class CategoryFilter(RequestDelegate next, CategoryStore store, PolicyTable policy)
{
    public async Task InvokeAsync(HttpContext ctx)
    {
        var host = ctx.Request.Host.Host.ToLowerInvariant();
        var category = store.Get(host);          // file, then learned cache
        if (category is null)
        {
            store.QueueForClassification(host);  // background worker calls ClassifyAsync
            category = "unclassified";
        }

        if (policy.Action(ctx.User, category) == "block")
        {
            ctx.Response.StatusCode = StatusCodes.Status403Forbidden;
            await ctx.Response.WriteAsync($"Blocked by policy: {category}");
            return;
        }
        await next(ctx);
    }
}

A BackgroundService reads the queue through a Channel<string>, calls ClassifyAsync a few hosts at a time, and writes results into the store. The first visit to an unknown host follows your unclassified policy. Every later visit uses the real category.

What should "unclassified" do?

Choose per network, and write the choice down:

Network Common choice
K-12 school Block until classified
Office Allow, log, review weekly
Public Wi-Fi Allow, except known high-risk categories
Kiosk Block

Very new domains appear disproportionately in phishing and fraud, so strict networks lose almost nothing by holding them for the short time classification takes.

Policies per tenant

MSPs and multi-site operators should separate two things that change at different speeds:

  • Facts: which category a domain has. Store these once and share them across all tenants.
  • Choices: what each tenant does with each category. Keep these in a small table per tenant.

A new customer then starts with every domain the platform has already learned, and a change in one customer's rules never affects another.

Exceptions and resilience

  • ArgumentException: empty key (constructor) or empty input (call).
  • ApiException: any non-success response, with StatusCode and Body. A 429 means pause the background worker. A 401 or 403 means a key or quota problem, so alert someone.
  • TaskCanceledException: timeout (30 seconds unless your own HttpClient says otherwise) or cancellation.

Because classification runs in the background, failures cost nothing visible: the host stays unclassified and is queued again on its next visit.

Privacy

The client sends the domain or URL you pass, your key, and nothing else. No client IPs, user names or request headers leave your proxy. When you classify full URLs, strip query strings first. They can contain session tokens or email addresses, and the host alone determines the category.

Schools and CIPA

In the United States, schools and libraries that receive E-rate support must filter under the Children's Internet Protection Act. Categories for adult content, weapons, gambling and anonymising proxies map directly onto those duties. Many districts now also want a separate decision for generative AI, allowing it in some classes and blocking it during exams. For that, add generative AI domains as their own category next to the main database.

Visibility before enforcement

Before tightening rules, see what people actually do. The log audit shows which staff reach AI tools, from firewall logs you already keep. For hosts your file and cache have never seen, on-demand classification of unknown hosts with IAB topics complements the filtering categories.

Testing your middleware

Build the client on an HttpClient with a stub handler that returns a fixed category, then assert that your middleware blocks or allows as the policy table says. The package's own tests use the same technique to confirm the key and query travel in the POST body.

Other ecosystems

For resolvers written in Go, use webfilteringdatabase-go. Flutter parental-control apps can call the pub.dev client. Rust appliances can use the crate.

License

MIT

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 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.
  • 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
1.0.1 120 9/25/2026
1.0.0 109 9/25/2026