SDKs
Official, open-source clients live at github.com/sunlicense-com. They all use the same two settings:
| Setting | Value |
|---|---|
| Base URL | https://api.sunlicense.com |
| Token | an API key from Dashboard → API keys (slk_…) |
Every SDK calls POST /api/v2/license/validate. HTTP 200 means valid; 400 means rejected, and the body's code says why (result codes). Pass a stable machine id as host so machine limits work.
java
// implementation 'com.sunlicense:sunlicense:0.0.1'
SunLicense client = new SunLicense.Builder()
.baseUrl("https://api.sunlicense.com")
.token(System.getenv("SUNLICENSE_TOKEN"))
.build();
SunLicense.Result result = client.validate(licenseKey, Map.of("host", machineId));
if (!result.isValid()) { /* result.getBody() has the code */ }js
// npm install sunlicense
import { SunLicense } from "sunlicense";
const client = new SunLicense({ baseUrl: "https://api.sunlicense.com", token: process.env.SUNLICENSE_TOKEN });
const result = await client.validate(licenseKey, { host: machineId });python
# pip install sunlicense
from sunlicense import SunLicense
client = SunLicense(base_url="https://api.sunlicense.com", token=os.environ["SUNLICENSE_TOKEN"])
result = client.validate(license_key, host=machine_id)csharp
// dotnet add package SunLicense
using var client = new SunLicenseClient("https://api.sunlicense.com",
token: Environment.GetEnvironmentVariable("SUNLICENSE_TOKEN"));
var result = await client.ValidateAsync(licenseKey, new Dictionary<string, string> { ["host"] = machineId });php
// composer require sunlicense/sunlicense
$client = new SunLicenseClient('https://api.sunlicense.com', token: getenv('SUNLICENSE_TOKEN'));
$result = $client->validate($licenseKey, ['host' => $machineId]);lua
-- luarocks install sunlicense (or drop sunlicense.lua into your FiveM/GMod resource)
local SunLicense = require("sunlicense")
local client = SunLicense.new({ baseUrl = "https://api.sunlicense.com", token = GetConvar("sunlicense_token", "") })
client:validate(licenseKey, { host = GetConvar("sv_hostname", "") }, function(ok, status, body) end)The Rust client (cargo add sunlicense) currently provides configuration only; validation is coming.
Choosing a machine id
Use something stable across reboots and updates: a hash of hardware identifiers, or an id you generate once and store. Don't use the IP address. The Java CLI's fingerprint command shows one approach.
Handling errors
| HTTP | Meaning | Recommended behaviour |
|---|---|---|
| 200 | Valid | Continue |
| 400 | Rejected (see code) | Block or prompt, depending on the code |
| 401 | Missing or wrong API key | A configuration bug in your app |
| 429 | Rate limited | Retry later |
| 5xx / network error | SunLicense is unreachable | Fall back to the offline license |
