A JavaScript client library for interacting with the Panda Development API service.
PelindaJS provides a simple and efficient way to manage license keys, validate users, and track executions for your software applications. Created by @spxnso on discord.
Installation
npm install pelindajs
Usage
First, import the PelindaJS class and create a new instance with your API key:
import { PelindaJS } from"pelindajs";asyncfunctionmain() {try {constpelinda=awaitPelindaJS.new("your-api-key-here");// Now you can use the pelinda instanceconsole.log("PelindaJS initialized successfully!"); } catch (error) {console.error("Failed to initialize PelindaJS:",error.message); }}main();
API Reference
Initialization
Creates a new PelindaJS instance with the provided API key. This method validates the API key before creating the instance.
Signature:
Parameters:
apiKey (string, required): Your Panda Development API key.
Example:
Get Execution Count
Retrieves the current execution count associated with your API key.
Signature:
Example:
Increment Execution Count
Increments the execution count associated with your API key.
Signature:
Example:
Generate Key
Generates new license keys with the specified parameters.
Signature:
Parameters (object):
Parameter
Type
Required?
Description
expire
string
Yes
Expiration date in YYYY-MM-DD format.
note
string
No
An optional note to attach to the key.
count
number
Yes
Number of keys to generate.
isPremium
boolean
Yes
Whether the key is for premium features.
expiresByDaysKey
boolean
No (defaults to false)
Whether the key expires by days.
daysKeys
number
Yes (if expiresByDaysKey is true)
Number of days before expiration.
Example:
Note: The npm documentation had a typo daysKey in the parameter description, but daysKeys in the example. I've used daysKeys based on the example, please verify the correct parameter name.
Delete Key
Deletes an activated key from the system.
Signature:
Parameters (object):
keyValue (string, required): The license key value to delete.
Example:
Check Identifier
Checks if an identifier exists in the system and returns service information.
Signature:
Parameters:
identifier (string, required): The identifier to check.
Example:
Extend Key Expiration
Extends the expiration date of a key by a specified number of days. (Note: expendKeyExpiration from npm docs, likely meant extendKeyExpiration).
Signature:
Parameters (object):
keyValue (string, required): The license key value to extend.
days (number, required): The number of days to extend the expiration by.
Example:
Fetch Key
Searches for and retrieves information about a specific key.
Signature:
Parameters:
searchTerm (string, required): The key value or other term to search for the key.
Example:
Delete Keyless
Deletes a keyless authentication entry by hardware ID (HWID).
Signature:
Parameters (object):
hwid (string, required): The hardware ID associated with the keyless entry to delete.
Example:
Fetch Generated Key
Searches for and retrieves information about a specific generated key (likely before activation/use).
Signature:
Parameters:
searchTerm (string, required): The key value or other term to search for the generated key.
Example:
Validate Key
Validates a license key against the service, optionally with a hardware ID (HWID).
Signature:
Parameters:
options (object, required):
keyValue (string, required): The license key to validate.
service (string, required): The name of your service this key is for.
hwid (string, optional): The hardware ID of the user. If not provided, PelindaJS might attempt to use a system-derived HWID (behavior depends on the library's internal implementation or the API).
keylessEnabled (boolean, optional, defaults to false): Whether keyless authentication is enabled for this validation attempt.
Example:
Examples
Complete Example - Key Management Workflow
Error Handling
Standard Response Object
All methods in PelindaJS return a promise that resolves to a standard response object with the following structure:
When a request fails (e.g., API error, validation error, network issue), the success property will be false, and the message property will contain details about the error. Always check the success property before attempting to use other data in the response.
async function checkExecutionCount() {
// Assuming pelinda is already initialized
// const pelinda = await PelindaJS.new("your-api-key");
const result = await pelinda.getExecutionCount();
if (result.success) {
console.log(`Current execution count: ${result.executionCount}`);
} else {
console.error(`Failed to get execution count: ${result.message}`);
}
}
const result = await pelinda.incrementExecutionCount();
async function incrementCount() {
// Assuming pelinda is already initialized
// const pelinda = await PelindaJS.new("your-api-key");
const result = await pelinda.incrementExecutionCount();
if (result.success) {
console.log(result.message); // e.g., "Execution count incremented successfully."
} else {
console.error(`Failed to increment execution count: ${result.message}`);
}
}
const result = await pelinda.generateKey({ /* options */ });
async function generateLicenseKeys() {
// Assuming pelinda is already initialized
// const pelinda = await PelindaJS.new("your-api-key");
const result = await pelinda.generateKey({
expire: "2025-12-31",
note: "Test license keys",
count: 5,
isPremium: true,
expiresByDaysKey: true,
daysKeys: 30, // Corrected from daysKey to daysKeys based on npm docs
});
if (result.success) {
console.log(`Generated keys:`, result.generatedKeys);
// Example: console.log(`First generated key: ${result.generatedKeys[0].value}`);
} else {
console.error(`Failed to generate keys: ${result.message}`);
}
}
const result = await pelinda.deleteKey({ keyValue });
async function deleteUserKey() {
// Assuming pelinda is already initialized
// const pelinda = await PelindaJS.new("your-api-key");
const result = await pelinda.deleteKey({
keyValue: "user-key-to-delete",
});
if (result.success) {
console.log(`Key deleted: ${result.deletedKey}`); // or use result.message
} else {
console.error(`Failed to delete key: ${result.message}`);
}
}
const result = await pelinda.checkIdentifier(identifier);
async function checkUserIdentifier() {
// Assuming pelinda is already initialized
// const pelinda = await PelindaJS.new("your-api-key");
const result = await pelinda.checkIdentifier("identifier-123");
if (result.success) {
console.log(`Identifier status: ${result.message}`);
console.log(`Service: ${result.service}`);
} else {
console.error(`Failed to check identifier: ${result.message}`);
}
}
const result = await pelinda.expendKeyExpiration({ keyValue, days });
async function extendKeyValidity() {
// Assuming pelinda is already initialized
// const pelinda = await PelindaJS.new("your-api-key");
const result = await pelinda.expendKeyExpiration({ // Using 'expend' as per npm doc
keyValue: "user-key-to-extend",
days: 60,
});
if (result.success) {
console.log(`Key extended: ${result.message}`);
console.log(`Updated key info:`, result.key);
} else {
console.error(`Failed to extend key: ${result.message}`);
}
}
const result = await pelinda.fetchKey(searchTerm);
async function lookupKey() {
// Assuming pelinda is already initialized
// const pelinda = await PelindaJS.new("your-api-key");
const result = await pelinda.fetchKey("user-key-to-fetch");
if (result.success) {
console.log(`Key details:`, result.key); // The npm docs say result.key, but example says result.result.key
// Assuming result.key is directly available
} else {
console.error(`Failed to fetch key: ${result.message}`);
}
}
const result = await pelinda.deleteKeyless({ hwid });
async function removeKeylessAuth() {
// Assuming pelinda is already initialized
// const pelinda = await PelindaJS.new("your-api-key");
const result = await pelinda.deleteKeyless({
hwid: "user-hardware-id",
});
if (result.success) {
console.log(result.message); // e.g., "Keyless entry deleted successfully."
} else {
console.error(`Failed to delete keyless entry: ${result.message}`);
}
}
const result = await pelinda.fetchGeneratedKey(searchTerm);
async function findGeneratedKey() {
// Assuming pelinda is already initialized
// const pelinda = await PelindaJS.new("your-api-key");
const result = await pelinda.fetchGeneratedKey("generated-key-value");
if (result.success) {
console.log(`Generated key details:`, result.generatedKey);
} else {
console.error(`Failed to fetch generated key: ${result.message}`);
}
}
const result = await pelinda.validateKey({ options }, keylessEnabled);
async function validateUserKey() {
// Assuming pelinda is already initialized
// const pelinda = await PelindaJS.new("your-api-key");
const result = await pelinda.validateKey(
{
service: "your-service-name",
keyValue: "user-key-to-validate",
hwid: "user-specific-hwid", // This is good practice to provide
}
// keylessEnabled defaults to false if not provided
);
if (result.success) {
console.log(`Validation successful. Result:`, result.result);
// Access specific parts of the result, e.g.,
// console.log(`Authentication status: ${result.result.V2_Authentication}`);
} else {
console.error(`Failed to validate key: ${result.message}`);
}
}
import { PelindaJS } from "pelindajs";
async function licenseManagementDemo() {
try {
// Initialize PelindaJS
const pelinda = await PelindaJS.new("YOUR_API_KEY_HERE");
console.log("PelindaJS Initialized.");
// Generate new license keys
const genResult = await pelinda.generateKey({
expire: "2025-06-30",
note: "Demo keys",
count: 2,
isPremium: true,
// Not specifying expiresByDaysKey or daysKeys, so it uses the 'expire' date.
});
if (genResult.success && genResult.generatedKeys && genResult.generatedKeys.length > 0) {
console.log(`Generated keys. First key: ${genResult.generatedKeys[0].value}`);
// Validate one of the generated keys
const keyToValidate = genResult.generatedKeys[0]; // This is an object with 'value', 'note', etc.
const validateResult = await pelinda.validateKey({
keyValue: keyToValidate.value,
service: "YOUR_SERVICE_NAME", // Replace with your actual service name
// hwid: "optional-demo-hwid" // Optionally provide a HWID
});
if (validateResult.success) {
console.log(`Key validation successful for ${keyToValidate.value}.`);
console.log("Validation Details:", validateResult.result);
// Extend the key's expiration
const extendResult = await pelinda.expendKeyExpiration({ // Using 'expend' as per docs
keyValue: keyToValidate.value,
days: 30,
});
if (extendResult.success) {
console.log(`Key expiration extended by 30 days for ${keyToValidate.value}.`);
console.log("Extended Key Info:", extendResult.key);
// Fetch the updated key information
const fetchResult = await pelinda.fetchKey(keyToValidate.value);
if (fetchResult.success) {
console.log(`Fetched updated key information:`, fetchResult.key); // Assuming .key from npm docs
} else {
console.error(`Failed to fetch updated key: ${fetchResult.message}`);
}
} else {
console.error(`Failed to extend key expiration: ${extendResult.message}`);
}
} else {
console.error(`Key validation failed for ${keyToValidate.value}: ${validateResult.message}`);
}
} else {
console.error(`Failed to generate keys: ${genResult.message}`);
}
// Check the execution count
const countResult = await pelinda.getExecutionCount();
if (countResult.success) {
console.log(`Current execution count: ${countResult.executionCount}`);
// Increment the execution count
const incrementResult = await pelinda.incrementExecutionCount();
if (incrementResult.success) {
console.log(`Execution count incremented: ${incrementResult.message}`);
// Check count again
const newCountResult = await pelinda.getExecutionCount();
if (newCountResult.success) {
console.log(`New execution count: ${newCountResult.executionCount}`);
}
} else {
console.error(`Failed to increment execution count: ${incrementResult.message}`);
}
} else {
console.error(`Failed to get execution count: ${countResult.message}`);
}
} catch (error) {
console.error(`Demo failed: ${error.message}`);
}
}
licenseManagementDemo();
{
"success": true, // or false
"message": "Descriptive message about the operation outcome.",
// Additional properties specific to the method, e.g.:
// "executionCount": 123, (for getExecutionCount)
// "generatedKeys": [ ... ], (for generateKey)
// "key": { ... }, (for fetchKey, expendKeyExpiration)
// "result": { ... } (for validateKey)
}