Skip to main content

CactusKIT

Lightweight Python SDK for declaring small API handlers and producing consistent responses.

See package metadata in pyproject.toml.

Overview

CactusKIT provides a single-purpose decorator cactuize to declare API entrypoints and a small response wrapper CactusResponse so handlers return consistent, serializable objects.

Key pieces:

  • cactuize(...) : decorator that validates/binds args, optionally enforces auth, and normalizes return values into CactusResponse.
  • CactusResponse / make_res() : response object and factory with helpers (size, hash, timestamp).
  • CactusEncoder : JSON encoder that can serialize CactusResponse instances.
  • Enums: HttpStatus, ApiProtocol, ApiMethod.

Installation

Install from source or PyPI when available:

pip install cactuskit

Usage

Import the symbols from the module and declare handlers with cactuize.

from cactuskit import ApiMethod, ApiProtocol, HttpStatus, cactuize

def authenticate():
    return True

@cactuize()
def simple_entrypoint():
    return f"Hello World from {simple_entrypoint}"

@cactuize(
    auth=authenticate,
    protocol=ApiProtocol.HTTP,
    method=ApiMethod.GET)
def entrypoint(name):
    return (HttpStatus.HTTP_CUSTOM(201), {
        "content": f"Hello {name}"
    })

Notes:

  • Handler functions may return a plain payload (dict or str) or a tuple (HttpStatus, payload).
  • If auth is provided to cactuize, it should be a callable returning truthy when authorized.

API Reference (short)

  • cactuize(protocol=ApiProtocol, method=ApiMethod, auth=None, middleware=None, args_mtable=None) : declare a function as a Cactus entrypoint. Performs argument binding and converts results into CactusResponse objects. When auth is provided, it is called and a failed check returns a plain "Authentication required" string.
  • CactusResponse(payload, status_code) : wrapper with helpers: get_payload(), get_status_code(), get_timestamp(), get_payload_size(), get_payload_hash().
  • make_res(payload, status_code=HttpStatus.HTTP_OK) : helper factory.
  • CactusEncoder : json.JSONEncoder subclass that serializes CactusResponse instances.

Development

  • Create a virtualenv and install dev dependencies (if any).
python -m venv .venv
source .venv/bin/activate
pip install -e .

Contributing

Contributions welcome. Open issues or pull requests and include tests for new behavior.

License

MIT : see LICENSE.

Metadata

Release files for cactuskit 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cactuskit 0.2.0
File Size Uploaded Provenance Actions
cactuskit-0.2.0.tar.gz 4.7 kB Without provenance Details for cactuskit-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cactuskit 0.2.0
File Interpreter ABI Platform Actions
cactuskit-0.2.0-py3-none-any.whl Python 3 none any Details for cactuskit-0.2.0-py3-none-any.whl

Total release size: 10.2 kB

Release files / cactuskit-0.2.0.tar.gz

Download URL cactuskit-0.2.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0f49346e685868f0f14a2c4ef5ee9afd8fd9295bbe479c66cbf453cfc83c317b
BLAKE2b-256 checksum
How to use checksums
86b7e1b874760457e6c3153cd233704a18a22fe78083ee1e1af56c0b6207be52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / cactuskit-0.2.0-py3-none-any.whl

Download URL cactuskit-0.2.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d6ad5ace72d85658f6becf05c3326a41078c70da2fc706ec12f6dc0d37f9720
BLAKE2b-256 checksum
How to use checksums
0c3f6a40b811557b591fcb1ff13c4a9324531dd5c00a4a59a1bec65a6c54b996
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Security for cactuskit 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page