Metadata-Version: 2.4
Name: licensekit-sdk
Version: 0.1.0a0
Summary: Python SDK for licensekit.dev
Project-URL: Homepage, https://licensekit.dev
Project-URL: Repository, https://github.com/drmain1/licensekit-python
Project-URL: Issues, https://github.com/drmain1/licensekit-python/issues
Requires-Python: >=3.11
Requires-Dist: httpx<1,>=0.27
Requires-Dist: pynacl<2,>=1.5
Provides-Extra: dev
Requires-Dist: build<2,>=1.2; extra == 'dev'
Requires-Dist: pytest<9,>=8.3; extra == 'dev'
Requires-Dist: pyyaml<7,>=6; extra == 'dev'
Description-Content-Type: text/markdown

# `licensekit-sdk`

Public Python SDK source for `licensekit.dev`.

This repository is the standalone home of the PyPI package `licensekit-sdk`. It contains the published client source, examples, tests, and the OpenAPI snapshot used to generate the typed client surface.

Links:

- product site: `https://licensekit.dev`
- hosted API: `https://api.licensekit.dev`
- TypeScript SDK: `https://www.npmjs.com/package/@licensekit/sdk`

## Install

```bash
pip install licensekit-sdk
```

## Quick Start

```python
from licensekit import (
    ManagementClient,
    PublicKeyStore,
    RuntimeClient,
    SystemClient,
    verify_runtime_result,
)

base_url = "https://api.licensekit.dev"

system = SystemClient(base_url=base_url)
health = system.health()
print(health["data"]["status"])

management = ManagementClient(
    base_url=base_url,
    token="lkm_..."
)

product = management.create_product(
    body={
        "name": "Example App",
        "code": "example-app",
    }
)

runtime = RuntimeClient(
    base_url=base_url,
    license_key="lsk_..."
)

result = runtime.validate_license(
    body={
        "fingerprint": "host-123",
    }
)

public_keys = system.list_public_keys()
verified = verify_runtime_result(
    result,
    PublicKeyStore(public_keys["data"]),
)

print(product["data"]["id"], verified.ok)
```

## Package Shape

- `ManagementClient`
  Uses `Authorization: Bearer <token>` for `/api/v1/...` management operations.
- `RuntimeClient`
  Uses `Authorization: License <license-key>` for `/api/v1/license/...` runtime operations.
- `SystemClient`
  Unauthenticated access to `/health`, `/healthz`, `/readyz`, `/metrics`, and `/api/v1/system/public-keys`.

Hosted deployments should prefer `/health` for liveness checks behind `api.licensekit.dev`.
`/healthz` remains available for local and self-hosted compatibility.

## Scope Metadata

```python
from licensekit import get_required_scopes, has_required_scopes

scopes = get_required_scopes("createProduct")
allowed = has_required_scopes("createProduct", ["product:write"])
```

## Raw Response Access

Each client exposes a `.raw` companion for callers that need status codes and headers.

```python
from licensekit import SystemClient

system = SystemClient(base_url="https://api.licensekit.dev")
ready = system.raw.readyz()

print(ready.status, ready.data["data"]["status"])
```

## Examples

Examples live in [`examples/`](./examples):

- `01_create_scoped_api_key.py`
- `02_runtime_validate_and_verify.py`

## Development

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -e '.[dev]'
python scripts/generate_from_openapi.py
pytest
python -m build
```

Generation uses the checked-in OpenAPI snapshot at [`openapi/openapi.yaml`](./openapi/openapi.yaml).
