Skip to main content

Official Python SDK for the smplkit platform

Project description

smplkit Python SDK

PyPI Version Build Coverage License Docs

The official Python SDK for smplkit — simple application infrastructure that just works.

Installation

pip install smplkit-sdk

Requirements

  • Python 3.10+

Quick Start

The SDK ships two top-level clients, each with a clearly-scoped purpose:

Client Use case Construction side effects
SmplClient / AsyncSmplClient Runtime instrumentation — flag evaluation, config reads, log emission Auto-registers a service context, starts a metrics thread, opens a websocket
SmplManagementClient / AsyncSmplManagementClient Management / CRUD — setup scripts, CI/CD, admin tooling None — pure HTTP setup

Runtime: SmplClient

from smplkit import SmplClient

with SmplClient(api_key="sk_api_...", environment="production", service="my-svc") as client:
    # Resolve config values for the current environment
    db = client.config.get("database")  # {"host": "...", "port": 5432}

    # Evaluate a flag against the current request context
    checkout_v2 = client.flags.booleanFlag("checkout-v2", default=False)
    if checkout_v2.get():
        ...

    # Opt in to runtime logging level control
    client.logging.start()

Management: SmplManagementClient

from smplkit import SmplManagementClient

with SmplManagementClient(api_key="sk_api_...") as mgmt:
    # Configs
    cfg = mgmt.configs.new("my_service", name="My Service")
    cfg.save()
    configs = mgmt.configs.list()

    # Flags
    flag = mgmt.flags.newBooleanFlag("checkout-v2", default=False)
    flag.save()
    flags = mgmt.flags.list()

    # Loggers + log groups
    logger = mgmt.loggers.new("sql", name="SQL Logger")
    logger.save()
    grp = mgmt.log_groups.new("databases", name="Databases")
    grp.save()

    # App-service-owned resources
    for env in mgmt.environments.list():
        print(env.id)
    mgmt.contexts.register([...])
    settings = mgmt.account_settings.get()

The management client takes only api_key (plus optional profile, base_domain, scheme, debug) — environment and service have no meaning for CRUD work and are deliberately rejected.

For async usage, swap SmplClientAsyncSmplClient and SmplManagementClientAsyncSmplManagementClient; method bodies become await-able:

from smplkit import AsyncSmplClient, AsyncSmplManagementClient

async with AsyncSmplClient(api_key="sk_api_...", environment="prod", service="svc") as client:
    db = await client.config.get("database")

async with AsyncSmplManagementClient(api_key="sk_api_...") as mgmt:
    cfg = await mgmt.configs.get("my_service")
    configs = await mgmt.configs.list()

Which client should I use?

  • Inside a request handler / running serviceSmplClient. You want lazy-fetched runtime state, the context registration loop, metrics, and the live-update websocket.
  • In a setup script / CI job / admin CLI / seederSmplManagementClient. No runtime side effects, no auto-registered service rows leaking into target accounts, no websocket dangling open.

The two clients can be used together in the same process — e.g. a runtime app that occasionally needs to reach into the management API for an admin endpoint.

Management namespaces

The SmplManagementClient exposes eight flat namespaces (one per resource family):

Namespace Resource
mgmt.contexts Context instances (register / list / get / delete)
mgmt.context_types Targeting-rule entity schemas
mgmt.environments Environments (built-ins + AD_HOC)
mgmt.account_settings Per-account settings
mgmt.configs Smpl Config CRUD
mgmt.flags Smpl Flags CRUD
mgmt.loggers Smpl Logging logger CRUD
mgmt.log_groups Smpl Logging log-group CRUD

Configuration

All settings are resolved from three sources, in order of precedence:

  1. Constructor arguments — highest priority, always wins.
  2. Environment variables — e.g. SMPLKIT_API_KEY, SMPLKIT_ENVIRONMENT.
  3. Configuration file (~/.smplkit) — INI-format with profile support.
  4. Defaults — built-in SDK defaults.

Configuration File

The ~/.smplkit file supports a [common] section (applied to all profiles) and named profiles:

[common]
environment = production
service = my-app

[default]
api_key = sk_api_abc123

[local]
base_domain = localhost
scheme = http
api_key = sk_api_local_xyz
environment = development
debug = true

Constructor Examples

# Use a named profile
client = SmplClient(profile="local")

# Or configure explicitly
client = SmplClient(
    api_key="sk_api_...",
    environment="production",
    service="my-service",
)

For the complete configuration reference, see the Configuration Guide.

Error Handling

All SDK errors extend SmplError:

from smplkit import SmplError, SmplNotFoundError

try:
    config = mgmt.configs.get("nonexistent")
except SmplNotFoundError:
    print("Config not found")
except SmplError as e:
    print(f"SDK error: {e}")
Exception Cause
SmplNotFoundError Resource not found
SmplConflictError Conflict (e.g., has children)
SmplValidationError Validation error
SmplTimeoutError Request timed out
SmplConnectionError Network connectivity issue
SmplError Any other SDK error

Debug Logging

Set SMPLKIT_DEBUG=1 to enable verbose diagnostic output to stderr. This is useful for troubleshooting real-time level changes, WebSocket connectivity, and SDK initialization. Debug output bypasses the managed logging framework and writes directly to stderr.

SMPLKIT_DEBUG=1 python my_app.py

Accepted values: 1, true, yes (case-insensitive). Any other value (or unset) disables debug output.

Documentation

License

MIT

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smplkit_sdk-3.1.2.tar.gz (275.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smplkit_sdk-3.1.2-py3-none-any.whl (421.3 kB view details)

Uploaded Python 3

File details

Details for the file smplkit_sdk-3.1.2.tar.gz.

File metadata

  • Download URL: smplkit_sdk-3.1.2.tar.gz
  • Upload date:
  • Size: 275.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for smplkit_sdk-3.1.2.tar.gz
Algorithm Hash digest
SHA256 2cead184455ea0009f35b22a23f3e2b88011b9e9ec2e687e8b20e8062ab57241
MD5 7855484b6e28d87775e3361c189e24b1
BLAKE2b-256 2e879a6c8f240a6117776bc5bcaa9e6e1cdab8af1ecca2a2bfba94c2e8b817a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for smplkit_sdk-3.1.2.tar.gz:

Publisher: ci-cd.yml on smplkit/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smplkit_sdk-3.1.2-py3-none-any.whl.

File metadata

  • Download URL: smplkit_sdk-3.1.2-py3-none-any.whl
  • Upload date:
  • Size: 421.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for smplkit_sdk-3.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 66e7368cbba747835565f0d04f4abb01b0c9a08452a9abf93e9609d6cb7860dc
MD5 36bce6acd359ecd724e4a4fb388c2888
BLAKE2b-256 e481797d4df2c096b94e4a2574f79f1763e34cc606b76ee0311088947e387234

See more details on using hashes here.

Provenance

The following attestation bundles were made for smplkit_sdk-3.1.2-py3-none-any.whl:

Publisher: ci-cd.yml on smplkit/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page