Moderyo 2.0.7
dotnet add package Moderyo --version 2.0.7
NuGet\Install-Package Moderyo -Version 2.0.7
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="Moderyo" Version="2.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Moderyo" Version="2.0.7" />
<PackageReference Include="Moderyo" />
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 Moderyo --version 2.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Moderyo, 2.0.7"
#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 Moderyo@2.0.7
#: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=Moderyo&version=2.0.7
#tool nuget:?package=Moderyo&version=2.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Moderyo .NET SDK
Official .NET client library for the Moderyo Content Moderation API.
Installation
dotnet add package Moderyo
Or via Package Manager:
Install-Package Moderyo
Quick Start
using Moderyo;
var client = new ModeryoClient("your-api-key");
// Moderate content
var result = await client.ModerateAsync("Hello, this is a test message");
Console.WriteLine($"Flagged: {result.Flagged}");
Console.WriteLine($"Action: {result.Action}");
Features
- ✅ Full async/await support
- ✅ .NET 6.0, 7.0, 8.0 support
- ✅ Dependency injection ready
- ✅ Automatic retry with exponential backoff
- ✅ Rate limiting handling
- ✅ Batch processing support
- ✅ ASP.NET Core middleware
Configuration
Basic Configuration
var client = new ModeryoClient(new ModeryoOptions
{
ApiKey = "your-api-key",
BaseUrl = "https://api.moderyo.com",
Timeout = TimeSpan.FromSeconds(30),
MaxRetries = 3
});
Dependency Injection
// Program.cs / Startup.cs
builder.Services.AddModeryo(options =>
{
options.ApiKey = builder.Configuration["Moderyo:ApiKey"];
});
// In your service
public class ContentService
{
private readonly IModeryoClient _moderyo;
public ContentService(IModeryoClient moderyo)
{
_moderyo = moderyo;
}
public async Task<bool> IsContentSafe(string content)
{
var result = await _moderyo.ModerateAsync(content);
return result.Action == Decision.Allow;
}
}
Configuration from appsettings.json
{
"Moderyo": {
"ApiKey": "your-api-key",
"BaseUrl": "https://api.moderyo.com",
"Timeout": "00:00:30",
"MaxRetries": 3
}
}
builder.Services.AddModeryo(builder.Configuration.GetSection("Moderyo"));
Usage Examples
Basic Moderation
var result = await client.ModerateAsync("User message here");
if (result.Flagged)
{
Console.WriteLine($"Content flagged: {result.Explanation}");
Console.WriteLine($"Action: {result.Action}");
}
With Context
var result = await client.ModerateAsync(new ModerationRequest
{
Content = "User message",
Context = new ModerationContext
{
UserId = "user_123",
ContentType = "chat",
Platform = "mobile"
}
});
Batch Processing
var messages = new[]
{
"Message 1",
"Message 2",
"Message 3"
};
var results = await client.ModerateBatchAsync(messages);
Console.WriteLine($"Total: {results.Total}");
Console.WriteLine($"Flagged: {results.FlaggedCount}");
Console.WriteLine($"Blocked: {results.BlockedCount}");
Check Specific Categories
var result = await client.ModerateAsync(content);
if (result.Categories.Violence)
{
Console.WriteLine($"Violence score: {result.Scores.Violence:P2}");
}
if (result.Categories.Harassment)
{
Console.WriteLine($"Harassment score: {result.Scores.Harassment:P2}");
}
Error Handling
try
{
var result = await client.ModerateAsync(content);
}
catch (AuthenticationException ex)
{
// Invalid API key
Console.WriteLine($"Auth error: {ex.Message}");
}
catch (RateLimitException ex)
{
// Rate limit exceeded
Console.WriteLine($"Rate limited. Retry after: {ex.RetryAfter}");
await Task.Delay(ex.RetryAfter);
}
catch (ValidationException ex)
{
// Invalid request
Console.WriteLine($"Validation error: {ex.Message}");
}
catch (ModeryoException ex)
{
// General API error
Console.WriteLine($"API error: {ex.Message}");
}
ASP.NET Core Middleware
Filter Attribute
[ApiController]
[Route("api/[controller]")]
public class MessagesController : ControllerBase
{
[HttpPost]
[ModerateContent("content")] // Auto-moderate the 'content' field
public async Task<IActionResult> CreateMessage([FromBody] MessageDto dto)
{
// Content is already moderated
// Check HttpContext.Items["ModerationResult"] for details
return Ok(new { status = "created" });
}
}
Middleware
app.UseModeryo(options =>
{
options.ModerateRoutes("/api/messages", "/api/comments");
options.OnBlocked = async context =>
{
context.Response.StatusCode = 400;
await context.Response.WriteAsJsonAsync(new
{
error = "Content blocked by moderation"
});
};
});
Minimal API
app.MapPost("/api/messages", async (
MessageDto dto,
IModeryoClient moderyo) =>
{
var result = await moderyo.ModerateAsync(dto.Content);
if (result.Action == Decision.Block)
{
return Results.BadRequest(new { error = "Content blocked" });
}
// Process message...
return Results.Ok();
});
Gaming Integration
public class GameChatService
{
private readonly IModeryoClient _moderyo;
public GameChatService(IModeryoClient moderyo)
{
_moderyo = moderyo;
}
public async Task<ChatResult> ProcessChatMessage(
string playerId,
string message)
{
var result = await _moderyo.ModerateAsync(new ModerationRequest
{
Content = message,
Context = new ModerationContext
{
UserId = playerId,
ContentType = "game_chat",
Platform = "game_client"
}
});
return result.Action switch
{
Decision.Allow => new ChatResult(true, message),
Decision.Flag => new ChatResult(true, message, Warning: true),
Decision.Block => new ChatResult(false, null, Blocked: true),
_ => new ChatResult(true, message)
};
}
}
Development
# Clone repository
git clone https://github.com/moderyo/moderyo-dotnet.git
cd moderyo-dotnet
# Build
dotnet build
# Run tests
dotnet test
# Pack for NuGet
dotnet pack -c Release
License
MIT License - see LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 is compatible. 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.
-
net7.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- System.Text.Json (>= 8.0.5)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- System.Text.Json (>= 8.0.5)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- System.Text.Json (>= 8.0.5)
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 |
|---|---|---|
| 2.0.7 | 89 | 2/16/2026 |