Skip to content

keymint-dev/Keymint-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keymint Python

A professional, production-ready SDK for integrating with the Keymint API in Python. Provides robust access to all major Keymint features, with type hints and modern error handling.

Features

  • Type hints: Full type hint support for better IDE integration and code safety.
  • Comprehensive: Complete API coverage for all Keymint endpoints.
  • Consistent error handling: All API errors are returned as structured objects or exceptions.
  • Security: Credentials are always loaded from environment variables.

Installation

Add the SDK to your project:

pip install keymint

Usage

import os
from keymint import KeyMint

access_token = os.environ.get('KEYMINT_ACCESS_TOKEN')
product_id = os.environ.get('KEYMINT_PRODUCT_ID')

if not access_token or not product_id:
    raise ValueError('Please set the KEYMINT_ACCESS_TOKEN and KEYMINT_PRODUCT_ID environment variables.')

sdk = KeyMint(access_token)

# Example: Create a key with authorized hosts
result = sdk.create_key({ 
    'productId': product_id,
    'allowedHosts': ['machine-a']
})

if result and 'key' in result:
    key = result['key']
    # ...

Error Handling

All SDK methods return a dictionary. If an API call fails, the SDK raises a KeyMintApiError exception with message, code, and status attributes.

API Methods

License Key Management

Method Description
create_key Creates a new license key.
activate_key Activates a license key for a device.
deactivate_key Deactivates a device from a license key.
get_key Retrieves detailed information about a key.
block_key Blocks a license key.
unblock_key Unblocks a previously blocked license key.

Customer Management

Method Description
create_customer Creates a new customer.
get_all_customers Retrieves all customers.
get_customer_by_id Gets a specific customer by ID.
get_customer_with_keys Gets a customer along with their license keys.
update_customer Updates customer information.
toggle_customer_status Toggles customer active status.
delete_customer Permanently deletes a customer and their keys.

License

MIT

Support

For help, see Keymint API docs or open an issue.