ReqHub 3.0.0

.NET Standard 2.0
dotnet add package ReqHub --version 3.0.0
NuGet\Install-Package ReqHub -Version 3.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="ReqHub" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ReqHub --version 3.0.0
#r "nuget: ReqHub, 3.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install ReqHub as a Cake Addin
#addin nuget:?package=ReqHub&version=3.0.0

// Install ReqHub as a Cake Tool
#tool nuget:?package=ReqHub&version=3.0.0


ReqHub middleware for C# projects. Distribute your API using the ReqHub platform in just a few lines! For more information, visit


ReqHub for .Net is available on NuGet:

Install-Package ReqHub

Distributing an API

To distribute an API for clients to consume with API keys, add these two lines to your Startup.cs:

/// Startup.cs

public class Startup
    public void ConfigureServices(IServiceCollection services)
        // Visit to get your API keys
        services.AddReqHub("yourPublicKey", "yourPrivateKey");

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        // ...
        // app.UseRouting();
        // Put this after app.UseRouting() and before app.UseEndpoints().
        // It verifies requests against the platform and either
        // continues execution or returns a 403 forbidden response
        // if the request is invalid (bad API key, contents tampered with, etc.)
        // app.UseEndpoints(...);
        // ...

That's it! 🎉

How it works

Clients consuming your API create a request hash using their own API keys, which the middleware forwards to the platform along with your request hash. If everything matches up on the platform, the request is allowed to continue.

Consuming an API

To consume an API, configure a client and inject it into your controllers/services.

/// Startup.cs

public class Startup
    // ...
    public void ConfigureServices(IServiceCollection services)
        // Visit to get your API keys
        services.AddApiClient("https://api-base-address", "yourClientPublicKey", "yourClientPrivateKey", "serviceName");
        // Add as many as you like!
        services.AddApiClient("https://api2-base-address", "anotherClientPublicKey", "anotherClientPrivateKey", "serviceName2");

(it looks like a lot of code, but we promise it isn't 👌):

/// ExampleController.cs

public class ExampleController : ControllerBase
    private readonly IApiClient exampleApiClient;

    // Resolve the API client using dependency injection
    public ExampleController(ApiClientResolver apiClientResolver)
        this.exampleApiClient = apiClientResolver("serviceName");

    public async Task<IEnumerable<Example>> Get()
        return await this.exampleApiClient.GetAsync<IEnumerable<Example>>("/example/endpoint");

.NET Framework

For those of you not using .NET Core, ReqHub supports .NET Framework (4.5+) WebApi projects.

/// FilterConfig.cs

public class FilterConfig
    public static void RegisterGlobalFilters(HttpFilterCollection filters)
        // ...
        filters.Add(new ReqHubAttribute("yourPublicKey", "yourPrivateKey"));

To consume an API:

// A little bit of setup
// (note that the HttpClient should be instantiated once and reused throughout the life of the application
var httpClient = HttpClientFactory.Create(new ReqHubClientHttpMessageHandler("yourClientPublicKey", "yourClientPrivateKey"));
httpClient.BaseAddress = new Uri("https://api-base-address");
var exampleApiClient = new ApiClient(httpClient);

await this.exampleApiClient.GetAsync<IEnumerable<Example>>("/example/endpoint");

Per-endpoint configuration

ReqHub can be configured on a per-endpoint or per-controller basis. This is useful if you only want to publish a portion of your API, or if you want to include multiple small APIs in a single server instance to reduce hosting costs.

Simply apply the ReqHub attribute and you're all set!

// ReqHub attribute on a single action method

[ReqHub(publicKey: "yourPublicKey", privateKey: "yourPrivateKey")]
public IActionResult Test()
    return this.Ok("Success!");

Placing the attribute at the controller level will apply to all its endpoints:

// ReqHub attribute on a controller

[ReqHub(publicKey: "yourPublicKey", privateKey: "yourPrivateKey")]
public class ExampleController : ControllerBase
    public IActionResult Test1()
        return this.Ok("Success!");
    public IActionResult Test2()
        return this.Ok("Success!");

The examples here were for the latest .Net, but the same applies to .Net Framework projects.

Plan information

Plan information can be accessed from the User object. You can use this data to change or restrict functionality by plan.

this.User.GetClientId();           // A clientId unique to the user
this.User.GetPlanName();           // The plan name as entered, like "Extra awesome"
this.User.GetNormalizedPlanName(); // The plan name whitespace and special characters removed, like "Extra-awesome"
this.User.GetPlanSku();            // The plan SKU as entered, like "Extra awesome SKU!!!"
this.User.GetNormalizedPlanSku();  // The plan SKU with whitespace and special characters removed, like "Extra-awesome-SKU"
this.User.IsTrial();               // Indicates whether the user is currently in a trial period

Check out our docs for testing pricing plans for more information.


Go for it! If we're missing something or you're running into a problem, either let us know in an issue or send us a pull request. We think we're pretty reasonable 😘


MIT, babe -- go nuts! 🎉

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

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
3.0.0 212 12/12/2021
2.3.0 289 11/23/2020
2.2.0 352 10/4/2020
2.1.4 316 8/14/2020
2.1.3 319 7/6/2020
2.1.2 337 7/6/2020
2.1.1 341 7/5/2020
2.1.0 341 7/2/2020
1.2.2 336 6/24/2020
1.2.1 299 6/19/2020
1.2.0 304 4/22/2020
1.1.3 331 3/27/2020
1.1.2 319 2/25/2020