Skip to content

massarom/keygen-python-sdk

Repository files navigation

Keygen Python Software Development Kit

A Python library to interact with the Kyegen API and handle licensing, user authentication, and machine activation.

This library is a work-in-progress and does not aim to cover the entirety of Keygen’s API, especially the Enterprise features.

This library plays well with projects already relying on Pydantic, as all objects are Pydantic models, but it uses synchronous API calls. For an async-capable Keygen client, see keygen-py, which is a wrapper around keygen-rs.

Disclaimer: this library is not officially endorsed nor supported by Keygen LLC.

Installation

You can install the package as any Python distribution via

pip install keygen-python-sdk

Alternatively, use your project management tool’s command, e.g. with uv:

uv add keygen-python-sdk

Configuration

Configuration is entirely done via environment variables. Any attribute from the keygen_python_sdk.config.Config class can be set in this way. You will need to set an environment variable starting with KEYGEN_ and then append the all-caps version of the attribute you want to set. For example, to set the Config.auth_token attribute:

KEYGEN_ATUH_TOKEN="prod-asdnfKSDAABSDh2q9Dsv3

See the docs for more details.

Quickstart

Given a license key SOME-LICENSE-V3, you can obtain a license object with:

import keygen_python_sdk as kg

lic = kg.validate_key("SOME-LICENSE-V3")

Development

To work on keygen-python-sdk you need

  • Python >= 3.10;
  • uv for project management;
  • just for running common commands.
uv sync
just docs test package