Python SDK
Use this page to integrate LicenseKit from Python with the first-party licensekit-sdk package.
Who This Is For
- Python developers building licensing into services, tools, or desktop-adjacent workflows
- AI agents generating Python integration code
- teams that want verification helpers and scope metadata in Python
When To Use This
Use this page when your integration language is Python and you want a first-party client instead of raw httpx calls.
How It Works
Install
bash
pip install licensekit-sdkPackage shape
The package exposes:
ManagementClientRuntimeClientSystemClientPublicKeyStoreverify_runtime_resultget_required_scopeshas_required_scopes
Auth split
ManagementClientusesAuthorization: Bearer <token>RuntimeClientusesAuthorization: License <license-key>SystemClientuses no auth
Reporting support
The management surface includes the reporting routes as part of the generated contract, so the Python SDK is the right place to call:
- activities
- usage summary
- usage ledger
- license audit
- customer summary
- subscription settlement
- export create, metadata lookup, and download
Scope metadata
The package exposes least-privilege scope helpers derived from OpenAPI:
python
from licensekit import get_required_scopes, has_required_scopes
assert get_required_scopes("createReportExport") == ("report:export",)
assert has_required_scopes("getUsageSummary", ["report:read"]) is TrueExample
Runtime validation and verification:
python
from licensekit import (
PublicKeyStore,
RuntimeClient,
SystemClient,
verify_runtime_result,
)
base_url = "https://api.licensekit.dev"
runtime = RuntimeClient(
base_url=base_url,
license_key="lsk_..."
)
system = SystemClient(base_url=base_url)
result = runtime.validate_license(
body={
"fingerprint": "sdk-example-host",
}
)
public_keys = system.list_public_keys()
verification = verify_runtime_result(
result,
PublicKeyStore(public_keys["data"])
)Reporting read example:
python
from licensekit import ManagementClient
management = ManagementClient(
base_url="https://api.licensekit.dev",
token="lkm_..."
)
activities = management.list_activities(
query={
"customer_id": "cust_123",
"limit": 50,
}
)Common Mistakes
- mixing
tokenandlicense_key - using the runtime client for reporting routes
- skipping signature verification because the runtime response already parsed cleanly
- using broad admin keys when
report:readorreport:exportwould be enough