Search payments, customers…Ctrl K
1API Integration
2Export Ninja Script
3Add Product
4Collect Payments

Integrate the licensing API into your NinjaScript.

The licensing API authenticates users against the remote server and grants access to your product for those with active plans. Paste the sample below into your indicator or strategy and replace the product code with the one from the Products screen.

MyLicensedIndicator.csC#
// Validate the customer's license against the 1P licensing server.
async Task<bool> ValidateLicenseHelper(string[] productCodes)
{
    string apiUrl = "https://licensing.1palgos.io/licensing/validate";

    if (!TryGetLicenseToken(out string licenseToken))
    {
        RequestLicenseCode(GetLicenseFilePath()); // prompt user to paste key
        return false;
    }

    string content = "{\"licenseToken\": \"" + licenseToken + "\", " +
                     "\"productCodes\": [\"" + string.Join("\",\"", productCodes) + "\"]}";

    var jsonContent = new StringContent(content, Encoding.UTF8, "application/json");
    HttpResponseMessage response = await client.PostAsync(apiUrl, jsonContent);
    response.EnsureSuccessStatusCode();

    string body = await response.Content.ReadAsStringAsync();
    return bool.Parse(body); // server returns "true" or "false"
}