Skip to content

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-sdk

Package shape

The package exposes:

  • ManagementClient
  • RuntimeClient
  • SystemClient
  • PublicKeyStore
  • verify_runtime_result
  • get_required_scopes
  • has_required_scopes

Auth split

  • ManagementClient uses Authorization: Bearer <token>
  • RuntimeClient uses Authorization: License <license-key>
  • SystemClient uses 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 True

Example

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 token and license_key
  • using the runtime client for reporting routes
  • skipping signature verification because the runtime response already parsed cleanly
  • using broad admin keys when report:read or report:export would be enough

Prototype docs shell for the rewrite workspace.