CactusKIT SDK package
Project description
CactusKIT
Lightweight Python SDK for declaring small API handlers and producing consistent responses.
See package metadata in pyproject.toml.
Quick links
- Source: https://github.com/qerdinger/cactuskit
- Requires: Python 3.10+
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 enforcesauth, and normalizes return values intoCactusResponse.CactusResponse/make_res(): response object and factory with helpers (size, hash, timestamp).CactusEncoder: JSON encoder that can serializeCactusResponseinstances.- 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 (
dictorstr) or a tuple(HttpStatus, payload). - If
authis provided tocactuize, 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 intoCactusResponseobjects. Whenauthis 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.JSONEncodersubclass that serializesCactusResponseinstances.
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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cactuskit-0.1.0.tar.gz.
File metadata
- Download URL: cactuskit-0.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8801db34f78d9738c747bc077d78b3e6b6632b85573e5eba4eed10201d2f758e
|
|
| MD5 |
7e48464767d7a04795b0048dce80e52f
|
|
| BLAKE2b-256 |
0cdb0da64ff4ad9ce82707109070a06aff553cf76a8951b3b5155af26fd9a4a6
|
File details
Details for the file cactuskit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cactuskit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8d351213281c47460753b92bbcec258ea15fa2b5d818324fa0b49468060df7d
|
|
| MD5 |
fb27eee85c089a1841cc7c1606631101
|
|
| BLAKE2b-256 |
79cf0014a89b9507119acd0d78e7975f47f1a55b62ae1478c7866e10421bb0da
|