.NET SDK

.NET SDK Documentation

Integrate Qawaid validation into your .NET applications with the official SDK. Supports REST and gRPC protocols.

Installation

bash
# Install via NuGet
dotnet add package Qawaid.Engine.Sdk

# Or via Package Manager Console
Install-Package Qawaid.Engine.Sdk

Requirements: .NET 8.0+ | Supports .NET 8, .NET 9, and .NET 10 applications.

Quick Start

Get up and running in under 5 minutes. Initialize the client and make your first validation call.

csharp
using Qawaid.Engine.Sdk;

// Initialize the client
var client = new QawaidClient(new QawaidOptions
{
    BaseUrl = "https://api.qawaid.ai",
    ApiKey = "your-api-key",
    TenantSlug = "your-tenant"
});

// Validate data against rules
var result = await client.ValidateAsync("credit-check", new
{
    ApplicantAge = 30,
    AnnualIncome = 75000,
    CreditScore = 720,
    RequestedAmount = 50000
});

if (result.IsValid)
    Console.WriteLine($"Passed {result.RulesPassed}/{result.RulesEvaluated} rules");
else
    foreach (var failure in result.Failures)
        Console.WriteLine($"[{failure.RuleCode}] {failure.Message}");

REST Client

The REST client provides full access to the Qawaid API with automatic retry, timeout, and error handling.

csharp
using Qawaid.Engine.Sdk;

// REST Client with full options
var client = new QawaidRestClient(new QawaidOptions
{
    BaseUrl = "https://api.qawaid.ai",
    ApiKey = "your-api-key",
    Timeout = TimeSpan.FromSeconds(30),
    EnableRetry = true,
    MaxRetryAttempts = 3
});

// List all rules
var rules = await client.GetRulesAsync(page: 1, pageSize: 20);
foreach (var rule in rules.Items)
    Console.WriteLine($"{rule.RuleId}: {rule.Name} ({rule.Status})");

// Create a new rule
var newRule = await client.CreateRuleAsync(new CreateRuleRequest
{
    RuleId = "MAX-AGE-001",
    Name = "Maximum Applicant Age",
    Category = RuleCategory.Eligibility,
    Severity = RuleSeverity.Error,
    Expression = new SimpleExpression("applicant.age", "LessThanOrEquals", "65")
});

// Evaluate a decision table
var tableResult = await client.EvaluateTableAsync("credit-matrix", new
{
    CreditScore = 720, LoanTerm = 30
});

gRPC Client

For high-throughput scenarios, the gRPC client provides up to 3x faster responses with streaming support.

csharp
using Qawaid.Engine.Sdk.Grpc;

// gRPC Client for high-throughput scenarios
var grpcClient = new QawaidGrpcClient(new GrpcOptions
{
    Endpoint = "https://grpc.qawaid.ai:443",
    ApiKey = "your-api-key",
    MaxReceiveMessageSize = 16 * 1024 * 1024 // 16MB
});

// Single validation (3x faster than REST)
var result = await grpcClient.ValidateAsync("credit-check", payload);

// Streaming batch validation
await foreach (var batchResult in grpcClient.ValidateStreamAsync(
    "credit-check", applicants))
{
    Console.WriteLine($"{batchResult.Id}: {batchResult.IsValid}");
}
Performance

gRPC uses HTTP/2 multiplexing and Protocol Buffers for ~65% smaller payloads and ~3x faster latency.

API Reference

MethodDescription
ValidateAsync(schema, data)Validate data against published rules
ValidateBatchAsync(schema, items)Batch validation of multiple payloads
GetRulesAsync(page, size)List rules with pagination
GetRuleAsync(id)Get a single rule by ID
CreateRuleAsync(request)Create a new validation rule
UpdateRuleAsync(id, request)Update an existing rule
PublishRuleAsync(id)Publish a draft rule
DeleteRuleAsync(id)Delete a rule
EvaluateTableAsync(id, inputs)Evaluate a decision table
GetAnalyticsSummaryAsync()Get analytics summary

Error Handling

csharp
try
{
    var result = await client.ValidateAsync("credit-check", data);
}
catch (QawaidAuthenticationException ex)
{
    // 401 - Invalid or expired API key
    Console.WriteLine($"Auth error: {ex.Message}");
}
catch (QawaidNotFoundException ex)
{
    // 404 - Schema or rule not found
    Console.WriteLine($"Not found: {ex.ResourceType} {ex.ResourceId}");
}
catch (QawaidRateLimitException ex)
{
    // 429 - Rate limit exceeded
    Console.WriteLine($"Rate limited. Retry after: {ex.RetryAfter}");
    await Task.Delay(ex.RetryAfter);
}
catch (QawaidValidationException ex)
{
    // 400 - Invalid request
    foreach (var error in ex.Errors)
        Console.WriteLine($"  {error.Field}: {error.Message}");
}
catch (QawaidException ex)
{
    // Base exception for all SDK errors
    Console.WriteLine($"SDK error [{ex.StatusCode}]: {ex.Message}");
}

Configuration

csharp
// appsettings.json configuration
{
  "Qawaid": {
    "BaseUrl": "https://api.qawaid.ai",
    "ApiKey": "your-api-key",
    "TenantSlug": "your-tenant",
    "Timeout": "00:00:30",
    "EnableRetry": true,
    "MaxRetryAttempts": 3,
    "EnableCaching": true,
    "CacheDuration": "00:05:00",
    "EnableCircuitBreaker": true
  }
}

// Register in DI container
builder.Services.AddQawaid(builder.Configuration.GetSection("Qawaid"));

// Or configure programmatically
builder.Services.AddQawaid(options =>
{
    options.BaseUrl = "https://api.qawaid.ai";
    options.ApiKey = Environment.GetEnvironmentVariable("QAWAID_API_KEY")!;
    options.EnableCaching = true;
    options.CacheDuration = TimeSpan.FromMinutes(5);
});
OptionDefaultDescription
BaseUrl--Qawaid API base URL
ApiKey--Your API key
TenantSlug--Tenant identifier
Timeout30sHTTP request timeout
EnableRetrytrueAuto-retry on transient failures
MaxRetryAttempts3Max retry count
EnableCachingfalseCache rule definitions locally
CacheDuration5mCache TTL
EnableCircuitBreakertrueCircuit breaker pattern

Ready to Integrate?

Start your free trial and integrate rule validation into your .NET application in minutes.

Qawaid — Business Rules Engine for Regulated Industries