Examples

Javascript:

const axios = require('axios')

try {
    const url = 'http://YOUR_URL/api/client';
	const licensekey = "LICENSE_KEY"; // Get this from a config file
	const product = 'PRODUCT_NAME';
	const api_key = 'API_KEY'; // The API key you specified in the Plex Licenses config.yml file-
        const hwid = 'PC_IDENTIFIER';

    const res = await axios.post(
   		url,
   		{
   		    licensekey,
   		    product,
                    hwid
   		},
   		{ headers: { Authorization: api_key }}
	);

   	if (!res.data.status_code || !res.data.status_id){
        await console.log("――――――――――――――――――――――――――――――――――――");
        await console.log('\x1b[31m%s\x1b[0m', 'Your license key is invalid!');
        await console.log('\x1b[31m%s\x1b[0m', `Create a ticket in our discord server to get one.`);
        await console.log("――――――――――――――――――――――――――――――――――――");
   	    return process.exit(1)
   	}

    if(res.data.status_overview !== "success"){
        await console.log("――――――――――――――――――――――――――――――――――――");
        await console.log('\x1b[31m%s\x1b[0m', 'Your license key is invalid!');
        await console.log('\x1b[31m%s\x1b[0m', `Create a ticket in our discord server to get one.`);
        await console.log("――――――――――――――――――――――――――――――――――――");
   		return process.exit(1);
   	} else {
        await console.log("――――――――――――――――――――――――――――――――――――");
        await console.log('\x1b[32m%s\x1b[0m', 'Your license key is valid!');
        await console.log('\x1b[36m%s\x1b[0m', "Discord ID: " + res.data.discord_id);
        await console.log("――――――――――――――――――――――――――――――――――――");
    }
} catch (err) {
    await console.log("――――――――――――――――――――――――――――――――――――");
    await console.log('\x1b[31m%s\x1b[0m', 'License Authentication failed');
    await console.log("――――――――――――――――――――――――――――――――――――");
    await console.log(error)
    await process.exit(1)
}

LUA:

PerformHttpRequest(
    "http://YOUR_URL/api/client",
    function(errorCode, resultData, headers)
        data = json.decode(resultData)
        if data.status_overview == "success" then
        print("^2[SCRIPT_NAME] Your license key is valid!")
        print("^2[SCRIPT_NAME] Discord ID: ".. data.discord_id .."")
    else
        print("^1[SCRIPT_NAME] Your license key is invalid!")
        print("^1[SCRIPT_NAME] Create a ticket in our discord server to get one.")
    end
    end,
    "POST",
    json.encode({licensekey = 'GET_LICENSE_KEY_FROM_CONFIG', product = 'YOUR_SCRIPT_NAME'}), {['Content-Type'] = 'application/json', ['Authorization'] = 'YOUR_API_KEY'}) 

Python:

import requests

licensekey = "YOUR_LICENSE_KEY" # Get this from a config file
product = "YOUR_PRODUCT_NAME"
api_key = "YOUR_API_KEY"
url = "http://YOUR_URL/api/client"


# Code
headers = {'Authorization': api_key}
data = {'licensekey': licensekey, 'product': product }
response = requests.post(url, headers=headers, json=data)
status = response.json()

if status['status_overview'] == "success":
    print("Your license key is valid!")
    print("Discord ID: " + status['discord_id'])
else:
    print("Your license key is invalid!")
    print("Create a ticket in our discord server to get one.")
    exit()

Java

(Thanks to TheDanniCraft for this!)

final String apiURL = "http://YOUR_URL/api/client";
final String apiKey = "YOUR_API_KEY";
final String licenseKey = "YOUR_LICENSE_KEY";
final String product = "YOUR_PRODUCT_NAME";

try {
    URL url = new URL(apiURL);
    HttpURLConnection connection = (HttpURLConnection)url.openConnection();
    connection.setRequestMethod("POST");
    connection.setRequestProperty("Content-Type", "application/json");
    connection.setRequestProperty("Authorization", apiKey);
    connection.setDoOutput(true);

    String jsonInputString = String.format("{\"licensekey\": \"%s\", \"product\": \"%s\"}", licenseKey, product);

    try(OutputStream outputStream = connection.getOutputStream()) {
    byte[] input = jsonInputString.getBytes("utf-8");
        outputStream.write(input, 0, input.length);
    }

    try(BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"))) {
        StringBuilder response = new StringBuilder();
        String responseLine = null;
        while ((responseLine = br.readLine()) != null) {
            response.append(responseLine.trim());
        }

        // You can use 3rd Party libarys to parse and handle the JSON object
        // I'm using javas inbuilt features to check the response string

        if(response.toString().contains("\"status_id\":\"SUCCESS\"")){
            System.out.println("Your license key is valid!");
        }
        else{
            System.out.println("Your license key is invalid!\nCreate a ticket in our discord server to get one.");
            System.exit(0);
        }
    }
} catch (Exception e) {
    throw new RuntimeException(e);
}

If you know any other programming languages and want to help make more examples, Please contact us on discord!

Last updated