Skip to content

Keycrate JavaScript SDK ​

Installation ​

bash
npm install keycrate

Quick Start ​

javascript
import { configurate } from "keycrate";

const client = configurate("https://api.keycrate.dev", "your-app-id");

// Authenticate with license
const result = await client.authenticate({ license: "your-license-key" });
if (result.success) {
    console.log("License verified!");
    console.log(`License key: ${result.data.key}`);
} else {
    console.log(`Error: ${result.message}`);
}

Authentication ​

License Key ​

javascript
const result = await client.authenticate({
    license: "your-license-key",
});

Username & Password ​

javascript
const result = await client.authenticate({
    username: "user@example.com",
    password: "password123",
});

With HWID (Hardware ID) ​

javascript
const result = await client.authenticate({
    license: "your-license-key",
    hwid: "device-id-12345",
});

Registration ​

javascript
const result = await client.register({
    license: "your-license-key",
    username: "newuser@example.com",
    password: "securepassword",
});

if (result.success) {
    console.log("Registration successful!");
} else {
    console.log(`Error: ${result.message}`);
}

API Reference ​

configurate(host, appId) ​

Creates and returns a client instance.

Parameters:

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

Returns: Client instance

client.authenticate(options) ​

Authenticate using either a license key or username/password.

Parameters:

  • options.license (string, optional): License key
  • options.username (string, optional): Username
  • options.password (string, optional): Password
  • options.hwid (string, optional): Hardware ID

Returns: Promise<{success: boolean, message: string, data: object|null}>

Note: Either license OR (username + password) must be provided.

client.register(options) ​

Register credentials for a license.

Parameters:

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

Returns: Promise<{success: boolean, message: string, data: object|null}>

Response Structure ​

All endpoints return a response with the following structure:

javascript
{
    success: boolean,
    message: string,
    data: {
        key: "license-key-string",
        expires_at: "2025-12-31T23:59:59Z",
        // Additional fields depending on the operation
    }
}

Error Handling ​

javascript
try {
    const result = await client.authenticate({ license: "key" });

    if (!result.success) {
        const message = result.message;
        const data = result.data;

        if (message.includes("expired")) {
            console.error("Your license has expired");
            if (data && data.expires_at) {
                console.error(`Expired on: ${data.expires_at}`);
            }
        } else if (message.includes("HWID")) {
            console.error("Device mismatch");
            if (data && data.hwid_reset_allowed) {
                console.error("You can reset your HWID");
            }
        } else {
            console.error(`Auth failed: ${message}`);
        }
    }
} catch (error) {
    console.error("Request failed:", error.message);
}

in-depth examples : ​

Repo Card