@licenseman/sdk
v1.0.0
Published
TypeScript client for the LicenseManager API: products, policies, customers, licenses, machines and releases.
Maintainers
Readme
LicenseManager TypeScript SDK
The official TypeScript SDK for the LicenseManager API: issue, manage and validate software licenses. Fully typed, built on fetch: works in Node.js, Deno, Bun, edge runtimes and browsers.
Documentation · API reference · Changelog
Requirements
Node.js 18 or later, or any runtime with fetch.
Installation
npm install @licenseman/sdkUsage
Create an API key in the LicenseManager app, then create a license after a sale:
import { Configuration, LicensesApi } from "@licenseman/sdk";
const licenses = new LicensesApi(
new Configuration({ apiKey: process.env.LICENSEMANAGER_API_KEY }),
);
const license = await licenses.createLicense({
productId: "x7Kp2QaZ",
createLicense: {
email: "[email protected]",
},
});And validate it from your application, which needs no API key:
import { LicensesApi } from "@licenseman/sdk";
const licenses = new LicensesApi();
const licenseToken = await licenses.validateKey({
productId: "x7Kp2QaZ",
validateKey: {
key: "7KQ2M-X9ZPA-H4TRC-WN6EY-B3JDF",
fingerprint: "4c:32:75:8f:9a:1e",
version: "1.4.2",
},
});Authentication
Most endpoints take an organization API key: keep it on your servers. The endpoints your application calls directly, like validating a key, take no credentials or a token scoped to a customer, license or machine. See authentication and scoped tokens.
import { Configuration } from "@licenseman/sdk";
// With an API key, from your backend:
const configuration = new Configuration({ apiKey: process.env.LICENSEMANAGER_API_KEY });
// With a token scoped to a customer, license or machine:
const scoped = new Configuration({ accessToken: token });Errors
Failed requests answer an error with a stable code to branch on, listed for each endpoint in the API reference. See errors.
import { ResponseError } from "@licenseman/sdk";
try {
await licenses.getLicense({ id: "l3Nv8KwB" });
} catch (error) {
if (error instanceof ResponseError) {
const { error: details } = await error.response.json();
console.error(error.response.status, details.code, details.message);
}
}Reference
Every method is documented, with its parameters and responses, in the docs folder:
| Class | Methods |
| --- | --- |
| LicensesApi | validateKey, listLicenses, createLicense, listCustomerLicenses, getLicense, deleteLicense, updateLicense, getLicenseStats, cancelLicense, sendLicenseKeys, getSigningKey |
| PortalApi | getPortal, requestPortalLink, createPortalLink, createBillingPortalSession, sendPortalLink |
| ProductsApi | listProducts, createProduct, getProduct, deleteProduct, updateProduct, resetProduct, uploadProductLogo, deleteProductLogo, getProductStats |
| PoliciesApi | listPolicies, createPolicy, getPolicy, deletePolicy, updatePolicy |
| CustomersApi | listCustomers, createCustomer, getCustomer, deleteCustomer, updateCustomer |
| MachinesApi | listMachines, getMachine, deactivateMachine |
| ReleasesApi | listReleases, createRelease, getRelease, deleteRelease, updateRelease |
| TokensApi | createCustomerToken, createLicenseToken, createMachineToken |
| EventsApi | listPolicyEvents, listLicenseEvents |
| IntegrationsApi | getStripeIntegration, connectStripe, disconnectIntegration, updateIntegration, checkIntegration, listStripePrices, createStripeMapping, deleteStripeMapping, updateStripeMapping, getPaddleIntegration, connectPaddle, listPaddlePrices, createPaddleMapping, getSlackIntegration, authorizeSlack, deleteSlackConnection, updateSlackConnection, testSlackConnection |
Versioning
This SDK follows semantic versioning and is generated from the OpenAPI document of the API: each release is listed in the changelog. Please don't open pull requests, they would be overwritten by the next release: open an issue instead.
License
See LICENSE.
