License Your Python Desktop App with Keymint in 5 Minutes
Python desktop apps, CLI tools, and data science pipelines all need licensing if you want to sell them. The Keymint Python SDK gives you license creation, activation, and device-locked verification with type hints and a clean API.
Installation
pip install keymintQuick Start
from keymint import KeyMint
admin = KeyMint(api_key="YOUR_ADMIN_API_KEY")
client = KeyMint(api_key="YOUR_CLIENT_API_KEY")
product_id = "prod_100"Creating a License Key
result = admin.create_key({
"productId": product_id,
"allowedHosts": ["workstation-1", "workstation-2"],
})
license_key = result["key"]Activating on a Device
result = client.activate_key({
"productId": product_id,
"licenseKey": "T8XTR-AI21B-2990H-85SB5",
"hostId": "workstation-1",
})
if result["code"] == 0:
print(f"Activated for: {result['licenseeName']}")Call activate_key on every launch — it validates the key and confirms the machine is authorized. If the key is expired, the host isn't allowed, or activations are exhausted, it returns a non-zero code.
Deactivating a Machine
client.deactivate_key({
"productId": product_id,
"licenseKey": "T8XTR-AI21B-2990H-85SB5",
"hostId": "workstation-1",
})This frees up an activation slot so the user can move their license to another machine.
Retrieving Key Info
Detailed key lookup requires a read-only or admin API key. Use this from your backend, not from distributed client code.
info = client.get_key({
"productId": product_id,
"licenseKey": "T8XTR-AI21B-2990H-85SB5",
})
# info["data"]["license"]["expirationDate"]
# info["data"]["license"]["maxActivations"]Error Handling
The SDK raises KeyMintApiError when an API call fails:
from keymint import KeyMintApiError
try:
result = client.activate_key({...})
except KeyMintApiError as e:
print(f"Error {e.code}: {e.message}")What's Next
The Python SDK also supports block_key, unblock_key, and full customer management (create_customer, get_customer_by_id, update_customer, etc.). Those management calls require an admin API key; detailed get_key lookup requires read-only or admin.
Install it with pip install keymint and check the Python SDK docs for the complete reference.