Topgg.Integrations 0.1.0

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

Topgg.Integrations

Build installable Top.gg integrations in ASP.NET Core.

Top.gg integrations let users connect your service to their project with one click. Instead of manually configuring a webhook URL, Top.gg performs a handshake with your service (integration.create), stores your webhook configuration, and then delivers signed webhook events to you. When the user disconnects, Top.gg sends integration.delete.

This library handles the entire handshake for you: receive and validate the connection, persist it, respond with the correct webhook payload, clean up on disconnect, and verify signatures on every delivered event.

Integrations require approval from Top.gg before they can be listed. You can build and run the handshake locally without approval.

Install

dotnet add package Topgg.Integrations

Quick start

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddTopggIntegrations(options =>
{
    // The URL Top.gg will POST integration.create/delete to.
    options.ConfigPath = "/api/integrations/config";

    // The webhook URL Top.gg will deliver events to for each connection.
    options.WebhookUrl = "https://your.bot/api/integrations/events";

    // The event scopes you subscribe to.
    options.Scopes = new[] { "vote.create" };
});

var app = builder.Build();

// Handle the integration.create/integration.delete handshake.
app.MapTopggIntegrations();

app.Run();

That's it. MapTopggIntegrations() exposes the handshake endpoint, stores each connection (with its connection_id and webhook_secret), and returns the exact payload Top.gg expects.

Handling delivered webhook events

Webhook events are delivered to your WebhookUrl, signed with each connection's secret. Verify them with WebhookSignature:

app.MapPost("/api/integrations/events", async (HttpContext context) =>
{
    using var reader = new StreamReader(context.Request.Body);
    var rawBody = await reader.ReadToEndAsync();

    var options = context.RequestServices
        .GetRequiredService<IOptions<TopggIntegrationOptions>>().Value;

    if (!WebhookSignature.IsValid(
            options.WebhookSecret!,                       // the connection's whs_ secret
            rawBody,
            context.Request.Headers["x-topgg-signature"],
            options.MaxSignatureAge))
    {
        return Results.Unauthorized();
    }

    var vote = JsonSerializer.Deserialize<VotePayload>(rawBody);
    return Results.Ok();
});

Verifying the handshake

Top.gg may sign handshake requests to your config URL as well. Enable RequireSignature and provide your secret:

options.RequireSignature = true;
options.WebhookSecret = "whs_your_handshake_secret";

Every inbound request is then checked with constant-time HMAC SHA-256 verification before any connection is stored. MaxSignatureAge (a TimeSpan) additionally rejects replayed requests older than the given window.

API overview

Member Description
AddTopggIntegrations(...) Registers the connection store, event dispatcher, and TopggIntegrationService.
UseTopggIntegrations() Middleware-based handshake handling (alternative to MapTopggIntegrations).
MapTopggIntegrations() Minimal-API endpoint for the handshake on ConfigPath.
TopggIntegrationService CreateAsync / DeleteAsync / DispatchAsync for programmatic control.
IIntegrationConnectionStore Persistent store for connections. Ships with an in-memory implementation; implement it to back with EF Core, Redis, etc.
WebhookSignature HMAC SHA-256 v1 signature verification with optional replay protection.

Configuration

TopggIntegrationOptions:

Property Default Description
ConfigPath /api/integrations/config Handshake endpoint path.
WebhookUrl "" Webhook URL returned to Top.gg for each connection.
Scopes null Event scopes subscribed to (e.g. ["vote.create"]).
RequireSignature false Verify signatures on handshake requests.
WebhookSecret null Secret used to verify handshake requests when RequireSignature is enabled.
MaxSignatureAge null Reject replayed signed requests older than this duration.
SignatureHeader x-topgg-signature Header containing the signature.
TraceHeader x-topgg-trace Header containing the delivery trace ID.

Event payloads

  • IntegrationCreateEvent / IntegrationDeleteEvent — the handshake requests Top.gg sends to your ConfigPath.
  • IntegrationResponse — what you return on integration.create: webhook_url and routes.

Tests

dotnet test

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
0.1.0 90 8/16/2026