.NET

VeriSec is the official library for .NET 8 and later. NuGet

Install#

Terminal
dotnet add package VeriSec

Create a client#

.NET
using VeriSec;

using var client = new VeriSecClient(Environment.GetEnvironmentVariable("VERISEC_API_KEY")); // sk_test_…

new VeriSecClient() reads VERISEC_API_KEY from the environment. VeriSecOptions sets Timeout and MaxRetries (default 2).

Make a call#

Every endpoint is an async method on its group: face.verify is client.Face.VerifyAsync(...).

.NET
var result = await client.Face.VerifyAsync(new FaceVerifyParams
{
    Image1 = Image.FromPath("selfie.jpg"),
    Image2 = Image.FromPath("id-photo.jpg"),
    Threshold = 0.8,
});

var doc = await client.Documents.ReadAsync(new DocumentReadParams
{
    ImageFront = Image.FromPath("id-front.jpg"),
});

Images are Image.FromPath, Image.FromBytes, Image.FromStream or Image.FromBase64. A Financial upload is a FileInput, such as FileInput.FromPath("cheque.jpg").

Errors#

.NET
try
{
    await client.Face.VerifyAsync(parameters);
}
catch (InsufficientCreditsException)
{
    Console.WriteLine("Top up credits."); // 402: nothing was charged
}
catch (InvalidRequestException e)
{
    Console.WriteLine($"{e.Code} {e.Param}: {e.Message}");
}
catch (RateLimitException e)
{
    Console.WriteLine($"Wait {e.RetryAfter?.TotalSeconds} s.");
}
catch (ApiException e)
{
    Console.WriteLine($"{e.Status} {e.Code} {e.RequestId}");
}

The family: InvalidRequestException, AuthenticationException, InsufficientCreditsException, PermissionException, NotFoundException, RateLimitException, ApiServerException, and ApiConnectionException with ApiTimeoutException, all from VeriSecException.

Webhooks#

.NET
var evt = Webhooks.ConstructEvent(body, name => request.Headers[name], secret);

See Webhooks for a full handler.