AlphaQuantum.WebsiteCategorizationAPI 1.0.0

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

AlphaQuantum.WebsiteCategorizationAPI

Categorise web pages by topic from .NET. Send an article URL, get back IAB content categories with confidence scores, and use them for contextual advertising, brand safety or content analytics. This is the .NET 8 client for page topic classification for publishers.

dotnet add package AlphaQuantum.WebsiteCategorizationAPI

Classify a page

using AlphaQuantum.WebsiteCategorizationAPI;

var wca = new WebsiteCategorizationAPIClient(Environment.GetEnvironmentVariable("AQ_API_KEY")!);
var r = await wca.ClassifyAsync("https://example.com/travel/lisbon-weekend-guide");

foreach (var c in r["categories"].EnumerateArray())
    Console.WriteLine($"T{c.GetProperty("tier")} {c.GetProperty("name").GetString()} {c.GetProperty("confidence").GetDouble():0.00}");

According to the published API reference, categories lists taxonomy nodes (id, name, tier, confidence), and meta carries a request ID and processing time. The client hands you the reply as Dictionary<string, JsonElement> without changing it.

Classify on publish, not on page view

An article's topic does not change between page views. The efficient pattern is one call when the article is published, and another only when its text changes. In an ASP.NET Core CMS, a Channel<T> plus a BackgroundService keeps the editor's save button fast:

public sealed class ClassificationQueue
{
    private readonly Channel<(int ArticleId, string Url)> _ch = Channel.CreateUnbounded<(int, string)>();
    public ValueTask EnqueueAsync(int id, string url) => _ch.Writer.WriteAsync((id, url));
    public IAsyncEnumerable<(int ArticleId, string Url)> ReadAllAsync(CancellationToken ct) => _ch.Reader.ReadAllAsync(ct);
}

public sealed class ClassificationWorker(ClassificationQueue q, WebsiteCategorizationAPIClient wca, IArticleStore store)
    : BackgroundService
{
    protected override async Task ExecuteAsync(CancellationToken ct)
    {
        await foreach (var (id, url) in q.ReadAllAsync(ct))
        {
            try { await store.SaveCategoriesAsync(id, await wca.ClassifyAsync(url, ct)); }
            catch (ApiException ex) when (ex.StatusCode == 429) { await Task.Delay(30_000, ct); await q.EnqueueAsync(id, url); }
        }
    }
}

Your publish handler calls EnqueueAsync. Categories are usually stored before the first reader arrives.

Sending topics to the ad server

Ad servers accept key-values with each ad request. A short list of confident category IDs is enough:

static string[] TopicKeys(Dictionary<string, JsonElement> r, double floor = 0.5, int max = 2) =>
    r["categories"].EnumerateArray()
        .Where(c => c.GetProperty("confidence").GetDouble() >= floor)
        .OrderByDescending(c => c.GetProperty("confidence").GetDouble())
        .Take(max)
        .Select(c => c.GetProperty("id").ToString())
        .ToArray();

Store the keys with the article and render them into the page's ad tag. Targeting then follows content, not cookies.

Brand safety needs a lower bar

For targeting, a moderate threshold is fine. For brand safety, inspect every returned category, including low-confidence ones, and send borderline pages to a person. Keep the full reply on record so reviewers can see what the classifier saw.

Tiers in reporting

Tier 1 gives about two dozen broad topics, which is right for dashboards and executive reports. Tier 2 adds the detail sales teams sell against. Deeper tiers matter mostly for brand safety lists. Store everything once, then choose the depth in each report.

Thin pages

Galleries, video-only pages, paywalled articles and script-heavy apps give a classifier little text. If a page returns weak categories, classify the site's section page or the bare domain, and reuse that label for the thin pages beneath it.

Reference

  • Constructor: WebsiteCategorizationAPIClient(string apiKey, HttpClient? httpClient = null, string baseUrl = "https://www.websitecategorizationapi.com/api"). Without an HttpClient, a 30 second timeout applies.
  • Method: Task<Dictionary<string, JsonElement>> ClassifyAsync(string value, CancellationToken ct = default).
  • Errors: ArgumentException for empty key or input, ApiException (StatusCode, Body) for HTTP failures, TaskCanceledException for timeouts.

The key is sent in the form body over HTTPS, as the endpoint expects.

Testing

Build the client on an HttpClient whose handler returns a fixed JSON reply, then test your queue worker and key selection without network access. The package ships tests that do this, including a check that a 429 becomes an ApiException with status 429.

Neighbouring data

Topics describe content. Other questions need other sources:

Other clients

websitecategorizationapi-go for Go services, the websitecategorization npm package for Node.js, and the Composer package for PHP sites.

License

MIT. IAB taxonomy names belong to IAB Technology Laboratory and are mentioned for compatibility only.

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 126 9/25/2026
1.0.0 110 9/25/2026