Skip to main content

Installation

npm install keyport-node

Setup and usage

1

Initialize the client

You can create a client by passing your API key directly, or by loading it from a config file.
import { KeyPort } from 'keyport-node';

const client = new KeyPort('kp_live_xxx');
When using a config file, load the client with KeyPort.fromConfigFile:
const client = await KeyPort.fromConfigFile('./keyport.json');
2

Validate a license key

Call client.validate with the license key you want to check:
const result = await client.validate({ license_key: 'ABCD-EFGH-IJKL-MNOP' });
This sends a POST /api/v1/validate request and returns the validation result.
3

Retrieve license details

Call client.getLicense with the license key to fetch full license details:
const detail = await client.getLicense('ABCD-EFGH-IJKL-MNOP');
This sends a GET /api/v1/license/:key request and returns the license detail object.

Full examples

import { KeyPort } from 'keyport-node';

const client = new KeyPort('kp_live_xxx');

// Validate a license key
const result = await client.validate({ license_key: 'ABCD-EFGH-IJKL-MNOP' });

// Retrieve full license details
const detail = await client.getLicense('ABCD-EFGH-IJKL-MNOP');
Store your API key in an environment variable or a keyport.json config file rather than hard-coding it in your source code.