UsageMonitor.Core 0.3.0

dotnet add package UsageMonitor.Core --version 0.3.0                
NuGet\Install-Package UsageMonitor.Core -Version 0.3.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="UsageMonitor.Core" Version="0.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UsageMonitor.Core --version 0.3.0                
#r "nuget: UsageMonitor.Core, 0.3.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.
// Install UsageMonitor.Core as a Cake Addin
#addin nuget:?package=UsageMonitor.Core&version=0.3.0

// Install UsageMonitor.Core as a Cake Tool
#tool nuget:?package=UsageMonitor.Core&version=0.3.0                

UsageMonitor

UsageMonitor is a .NET library that provides API usage monitoring, rate limiting, and analytics capabilities for ASP.NET Core applications. It allows you to easily track API usage, implement rate limiting, and provide usage insights through a built-in dashboard.

Features

  • ⚡ Rate Limiting per API Client
  • 📊 Usage Analytics Dashboard
  • 📈 Request Logging
  • 🕒 Response Time Tracking
  • 💾 Multiple Database Support (SQLite, PostgreSQL, SQL Server)
  • 🔍 Built-in Admin Interface
  • 📱 Usage Monitoring UI

Installation

dotnet add package UsageMonitor.Core

Quick Start

  1. Add UsageMonitor to your services in Program.cs:
builder.Services.AddUsageMonitor(options =>
{
    options.ConnectionString = "Data Source=requests.db";
    options.DatabaseProvider = DatabaseProvider.SQLite;
});
  1. Configure the middleware and endpoints:
app.UseUsageMonitor();
app.MapUsageMonitorEndpoints();
app.MapUsageMonitorPages();
  1. Add the [MonitorUsage] attribute to controllers or actions you want to monitor:
[ApiController]
[Route("[controller]")]
[MonitorUsage]
public class WeatherForecastController : ControllerBase
{
    // Your controller code
}

Configuration

Database Providers

UsageMonitor supports SQLite, PostgreSQL, and SQL Server:

// For SQLite
options.DatabaseProvider = DatabaseProvider.SQLite;
options.ConnectionString = "Data Source=usagemonitor.db";

// For PostgreSQL
options.DatabaseProvider = DatabaseProvider.PostgreSQL;
options.ConnectionString = "Host=localhost;Database=usagemonitor;Username=user;Password=password";

// For SQL Server
options.DatabaseProvider = DatabaseProvider.SQLServer;
options.ConnectionString = "Server=localhost;Database=usagemonitor;Trusted_Connection=True;TrustServerCertificate=True";

Features

Rate Limiting

  • Configure usage limits per API client
  • Automatic rate limit enforcement
  • Monthly usage tracking

Usage Monitoring

  • Request/response logging
  • Response time tracking
  • Error rate monitoring
  • Usage statistics

Admin Dashboard

  • View all API clients
  • Manage usage limits
  • Monitor API usage
  • Generate usage reports

Client Usage Page

  • Self-service usage monitoring
  • Usage statistics visualization
  • Request history

Security

  • Secure admin interface with username/password authentication

Example Implementation

Check out the UsageMonitor.TestApi project in the solution for a complete example of how to integrate and use the library.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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. 
Compatible target framework(s)
Included target framework(s) (in package)
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
0.3.0 16 11/21/2024
0.2.0 19 11/21/2024
0.1.0 33 11/20/2024