Skip to content

Keycrate C# SDK ​

Installation ​

bash
dotnet add package Keycrate

Quick Start ​

csharp
using Keycrate;

var client = new KeycrateClient("https://api.keycrate.dev", "your-app-id");

var result = await client.AuthenticateAsync(new AuthenticateOptions
{
    License = "your-license-key"
});

if (result.Success)
{
    Console.WriteLine("License verified!");
    if (result.Data != null)
    {
        var data = result.Data as Dictionary<string, object>;
        if (data?.TryGetValue("key", out var key) == true)
            Console.WriteLine($"License key: {key}");
    }
}
else
{
    Console.WriteLine($"Error: {result.Message}");
}

Authentication ​

License Key ​

csharp
var result = await client.AuthenticateAsync(new AuthenticateOptions
{
    License = "your-license-key"
});

Username & Password ​

csharp
var result = await client.AuthenticateAsync(new AuthenticateOptions
{
    Username = "user@example.com",
    Password = "password123"
});

With HWID (Hardware ID) ​

csharp
var result = await client.AuthenticateAsync(new AuthenticateOptions
{
    License = "your-license-key",
    Hwid = "device-id-12345"
});

Registration ​

csharp
var result = await client.RegisterAsync(new RegisterOptions
{
    License = "your-license-key",
    Username = "newuser@example.com",
    Password = "securepassword"
});

if (result.Success)
{
    Console.WriteLine("Registration successful!");
}
else
{
    Console.WriteLine($"Error: {result.Message}");
}

API Reference ​

KeycrateClient(host, appId) ​

Constructor for creating a new client instance.

Parameters:

  • host (string): Base URL of the API
  • appId (string): Your application ID

AuthenticateAsync(AuthenticateOptions options) ​

Authenticate using either a license key or username/password.

Parameters:

  • options.License (string): License key
  • options.Username (string): Username
  • options.Password (string): Password
  • options.Hwid (string): Hardware ID

Returns: Task<AuthResponse>

Note: Either License OR (Username + Password) must be provided.

RegisterAsync(RegisterOptions options) ​

Register credentials for a license.

Parameters:

  • options.License (string): License key (required)
  • options.Username (string): Username (required)
  • options.Password (string): Password (required)

Returns: Task<AuthResponse>

Response Structure ​

All endpoints return a response with the following structure:

csharp
public class AuthResponse
{
    public bool Success { get; set; }
    public string Message { get; set; }
    public object Data { get; set; }  // Dictionary or null
}

The Data field contains additional information depending on the operation:

json
{
    "key": "license-key-string",
    "expires_at": "2025-12-31T23:59:59Z",
    "hwid_reset_allowed": true,
    "last_hwid_reset_at": "2025-01-15T10:30:00Z",
    "hwid_reset_cooldown": 86400
}

Error Handling ​

csharp
try
{
    var result = await client.AuthenticateAsync(new AuthenticateOptions
    {
        License = "key"
    });

    if (!result.Success)
    {
        var message = result.Message;
        var data = result.Data as Dictionary<string, object>;

        if (message.Contains("expired"))
        {
            Console.WriteLine("Your license has expired");
            if (data?.TryGetValue("expires_at", out var expires) == true)
                Console.WriteLine($"Expired on: {expires}");
        }
        else if (message.Contains("HWID"))
        {
            Console.WriteLine("Device mismatch");
            if (data?.TryGetValue("hwid_reset_allowed", out var allowed) == true)
                Console.WriteLine("You can reset your HWID");
        }
        else
        {
            Console.WriteLine($"Auth failed: {message}");
        }
    }
}
catch (Exception ex)
{
    Console.WriteLine($"Request failed: {ex.Message}");
}

in-depth examples : ​

Repo Card