NAV
shell javascript

Introduction

Welcome to the Lisenser API documentation! Lisenser is a service that makes it easy for you to manage the licensing of your Software (typically Desktop App, but it can also work for other kinds of Apps really).

Here, you will find all the endpoints available on the Lisenser REST API. You can use your favorite HTTP/REST library for making requests, or you can use one of the Lisenser Client Libraries for your platform.

Typical Usage Flow

  1. Create a Lisenser Account

  2. Create a New Product (this is basically a representation of your Application)

  3. Now you can use The Admin Endpoints on your App's server to generate License Keys and send them to your customers. If you don't intend to run your own servers you can consider using our Paypal callback instead.

  4. You can now proceed to your client (possibly your Desktop Application):

    • If your Application is written with Electron, then the Lisenser Electron Clien is recommended.
    • If your Application is written with any other Javascript based engine (e.g Node WebKit), then the Lisenser Javascript Client is recommended.
    • If your Application is not built with any of the above, then your goto is The App Endpoints. Essentially you'll be communicating with the endpoints to validate user's License Key, begin their trial status, etc.

Authentication

The Lisenser API has two kinds of Endpoints:

Making calls to the App Endpoints does not require any form of Authentication. Whereas, making calls to the Admin Endpoints requires you to provide your Admin API Key in the header of your requests.

App Endpoints

The App Endpoints consist of endpoints which you can use to validate a user's License Key from within your Application, start a Trial Period (if applicable to your app), etc.

For example, when your Application is launched, you may make a request to our Get License Status to see if the user has a valid License Key before going ahead to display the UI of your Application.

Get License Status

curl -X POST "https://api.lisenser.com/v1/license/status" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"key\": \"your-license-key\",  \"machineId\": \"your-machine-id\",  \"productId\": \"your-product-id\"}"
const axios = require('axios')

const body = {
  key: 'your-license-key',
  machineId: 'your-machine-id',
  productId: 'your-product-id'
}

axios.post('https://api.lisenser.com/v1/license/status', body)
  .then(res => console.log(res.data))
  .catch(err => console.error(err))

The above command returns JSON structured like this:

{
  "data": {
    "isActive": true,
    "status": "active",
    "daysToExpiry": 10
  }
}

Returns the current status of a license.

Request

POST https://api.lisenser.com/v1/license/status

Body

Field Type Description
key string The license key.
machineId string A unique identifier of the machine/device which is running your Application.
productId string Your Product ID.

Response

A JSON object with the following fields:

Field Type Description
isActive boolean Indicates whether the license is currently active.
status string The current status of the license. One of expired, active, or invalid.
daysToExpiry number The number of days until the license expires, if applicable. null if the license is not set to expire.

Activate License Key

curl -X POST "https://api.lisenser.com/v1/license/activate" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"key\": \"your-license-key\",  \"machineId\": \"your-machine-id\",  \"productId\": \"your-product-id\"}"
const axios = require('axios')

const body = {
  key: 'your-license-key',
  machineId: 'your-machine-id',
  productId: 'your-product-id'
}

axios.post('https://api.lisenser.com/v1/license/activate', body)
  .then(res => console.log(res.data))
  .catch(err => console.error(err))

The above command returns JSON structured like this:

{
  "data": {
    "isActive": true,
    "status": "active",
    "daysToExpiry": 10
  }
}

Activates a license key.

Request

POST https://api.lisenser.com/v1/license/activate

Body

Field Type Description
key string The license key.
machineId string A unique identifier of the machine/device which is running your Application.
productId string Your Product ID.

Response

A JSON object with the following fields:

Field Type Description
isActive boolean Indicates whether the license is currently active.
status string The current status of the license. One of expired, active, or invalid.
daysToExpiry number The number of days until the license expires, if applicable. null if the license is not set to expire.

Get Trial Status

curl -X POST "https://api.lisenser.com/v1/trial/status" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"machineId\": \"your-machine-id\",  \"productId\": \"your-product-id\"}"
const axios = require('axios')

const body = {
  machineId: 'your-machine-id',
  productId: 'your-product-id'
}

axios.post('https://api.lisenser.com/v1/trial/status', body)
  .then(res => console.log(res.data))
  .catch(err => console.error(err))

The above command returns JSON structured like this:

{
  "data": {
    "isActive": true,
    "status": "active",
    "daysToExpiry": 10
  }
}

Returns the current status of a trial period.

Request

POST https://api.lisenser.com/v1/trial/status

Body

Field Type Description
machineId string A unique identifier of the machine/device which is running your Application.
productId string Your Product ID.

Response

A JSON object with the following fields:

Field Type Description
isActive boolean Indicates whether the trial period is currently active.
status string The current status of the trial period. One of expired, active, not-started, or not-allowed.
daysToExpiry number The number of days until the trial period expires.

Start Trial

curl -X POST "https://api.lisenser.com/v1/trial/activate" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"machineId\": \"your-machine-id\",  \"productId\": \"your-product-id\"}"
const axios = require('axios')

const body = {
  machineId: 'your-machine-id',
  productId: 'your-product-id'
}

axios.post('https://api.lisenser.com/v1/trial/activate', body)
  .then(res => console.log(res.data))
  .catch(err => console.error(err))

The above command returns JSON structured like this:

{
  "data": {
    "status": "started"
  }
}

Activates a trial period.

Request

POST https://api.lisenser.com/v1/trial/activate

Body

Field Type Description
machineId string A unique identifier of the machine/device which is running your Application.
productId string Your Product ID.

Response

A JSON object with the following fields:

Field Type Description
data string The status of the trial period activation. One of started, not-allowed, or conflict

Admin Endpoints

The Admin Endpoints are used to create License Keys on behalf of your users. The Admin Endpoints require an Admin API Key, and SHOULD only be invoked in your server code where your API Key is not exposed to the general public.

A typical use-case for the Admin Endpoints would be to generate a new License key for a user once you validate that they've made a successful Payment via your Payment provider (e.g Stripe, Paypal, etc.)

Create License Key

curl -X POST "https://api.lisenser.com/v1/admin/license/create" -H  "accept: application/json" -H  "Content-Type: application/json" -H "X-Admin-Key: your-admin-api-key-here" -d "{  \"productId\": \"your-product-id\",  \"sendTo\": \"your.user@example.com\"}"
const axios = require('axios')

const body = {
  productId: 'your-product-id',
  sendTo: 'your.user@example.com'
}

const adminApiKey = 'your-admin-api-key-here'

axios.post('https://api.lisenser.com/v1/admin/license/create', body, {headers: {'x-admin-key': adminApiKey}})
  .then(res => console.log(res.data))
  .catch(err => console.error(err))

The above command returns JSON structured like this:

{
  "data": {
    "key": "THE-GENERATED-LICENSE-KEY"
  }
}

Returns the generated License Key.

Request

POST https://api.lisenser.com/v1/admin/license/create

Headers

Header Name Description
X-Admin-Key Your Admin API Key

Body

Field Type Description
productId string Your Product ID.
sendTo (optional) string An email address that the License Key should be sent to after creation. This is ideally the email address of the customer who paid for the License Key

Response

A JSON object with the following fields:

Field Type Description
key string The License Key which was generated

Client Libraries

At the moment, there are only Client Libraries for the App Endpoints. If you want to communicate with the Admin Endpoints you will need to communicate using the preferred HTTP Library of your Programming Language.

JavaScript Client

We have Offical JavaScript SDK that makes it easier to communicate with the App Endpoints. It is available on npm and you can simply install it with the command:

npm install lisenser

Please visit its Documentation Page for more

Electron Client

If your Application is a Desktop Application built with Electronjs, we have an Electron Client library that comes out of the box with handle License Key collection, validation, local storage, etc. You don't have to worry about generating a Machine Id as it also handled this.

It is available on npm and can be installed with the command:

npm install electron-lisenser

Please visit its Documentation Page for more

Paypal Callback

If you don't want to run your own server for your Application and you have set up a Paypal account to receive payments for your Application's License. Lisenser provides an easy integration to automatically send an email containing the purchased License to your customers once their Paypal payment is successfully completed.

It's as easy as that! You've gotten away with not running your own License server!.