Quickstart

You can setup Keyforge in your project within minutes. This guide will walk you through the steps to get started. You will create your first license, activate it, and then validate it.

Prerequisites

Before we begin, make sure you have completed the following steps:

  • Get an API key here.
  • Create a product here.

Install

Install the Keyforge Node.js SDK.

npm install keyforge-js

Create a license

Create a license for your product. In this example, we will create a license that never expires and can only have 1 device active at the same time. The license key will be logged to the console, copy it.

import { Keyforge } from 'keyforge-js';
 
const keyforge = new Keyforge('<YOUR_API_KEY>');
 
const license = await keyforge.licenses.create({
  productId: '<YOUR_PRODUCT_ID>',
  type: 'perpetual',
  maxDevices: 1,
});
 
console.log(license.key);

Activate a license

Activate the license you have just created. Replace LICENSE_KEY with the license key you copied in the previous step. In this example, we will activate the license on a device with the identifier some_device_id and the name My computer name.

await keyforge.licenses.activate('LICENSE_KEY', {
  productId: '<YOUR_PRODUCT_ID>',
  device: {
    identifier: 'some_device_id',
    name: 'My computer name',
  },
});

Validate a license

Validate the license you have just activated. Replace LICENSE_KEY with the license key, and <YOUR_PRODUCT_ID> with the product ID. In this example, we will validate the license on the device with the identifier some_device_id and see if it's valid.

const validation = await keyforge.licenses.validate('LICENSE_KEY', {
  deviceIdentifier: 'some_device_id',
  productId: '<YOUR_PRODUCT_ID>',
});
 
console.log(validation.isValid);

Congratulations! 🎉

You have successfully created, activated, and validated your first license. Your licenses are also available in the dashboard.

Learn more

Public API

Keyforge also provides a public REST API that you can use directly in your apps without the need to create a backend. An API key is not needed for the public API.

API Reference

Learn more about the SDK.