Skip to main content

JEC-API

A powerful wrapper around FastAPI that brings class-based routing, strict method mapping, and modern developer tools to your API development.

Features

  • Class-Based Routes: Group related endpoints into a single class for better organization.
  • Strict Method Mapping: Methods named get, post, put, etc., are automatically mapped to HTTP verbs.
  • Data Object Support: Native Pydantic integration for automatic request/response validation and schema generation.
  • API Decorators: Built-in @log, @speed, and @version decorators for observability and control.
  • Programmatic Configuration: Unified core.tinker() method to configure FastAPI and Uvicorn.
  • JEC DevTools: Real-time, dark-themed developer console at /__dev__ for monitoring traffic and performance.

Installation

pip install jec-api

Quick Start

  1. Define a Route Class
from pydantic import BaseModel
from jec_api import Route, log, speed

class UserResponse(BaseModel):
    id: int
    name: str

class Users(Route):
    @log
    @speed
    async def get(self) -> list[UserResponse]:
        """List all users with logging and speed tracking"""
        return [UserResponse(id=1, name="Alice")]
  1. Configure and Run
from jec_api import Core
from routes import Users

core = Core()
core.tinker(
    title="My API",
    dev=True,      # Enable JEC DevTools
    reload=True    # Auto-reload on changes
)

core.register(Users)

if __name__ == "__main__":
    core.run(port=8000)

Usage Guide

Defining Routes

Inherit from jec_api.Route. The class name is converted to kebab-case for the base path (e.g., UserProfiles -> /user-profiles), unless overridden with the path attribute.

Method Mapping

Methods named exactly after HTTP verbs (e.g., get, post) are registered as endpoints. Others are ignored.

API Decorators

Enhance your endpoints with built-in decorators:

  • @log: Logs function calls, arguments, and return values/exceptions.
  • @speed: Measures execution time in milliseconds.
  • @version(">=1.0.0"): Enforces semver constraints via the X-API-Version header.

Configuration (core.tinker())

The tinker() method provides a unified interface for configuration:

  • FastAPI Options: title, description, version, docs_url, etc.
  • Uvicorn Options: host, port, reload, log_level, etc.
  • DevTools: Set dev=True to enable the developer console.
  • Versioning: strict_versioning=True to require version headers on all versioned routes.

JEC DevTools

Access a premium, real-time monitoring dashboard at /__dev__ (or your custom dev_path). It provides:

  • Live request/response tracking via SSE.
  • Visual execution timing (Green/Yellow/Red).
  • Expanded logs for @log decorated methods.
  • Version check results.

License

MIT License

Release files for jec-api 0.1.3

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

Source distribution (sdist)

Source distribution for jec-api 0.1.3
File Size Uploaded
jec_api-0.1.3.tar.gz 7.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for jec-api 0.1.3
File Interpreter ABI Platform
jec_api-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 7.4 MB

Release files / jec_api-0.1.3.tar.gz

Download URL jec_api-0.1.3.tar.gz
Size 7.3 MB
Tags Source
SHA-256 checksum
How to use checksums
f1f5e437a7f9c1b7359ef7c103d5537a95a279044921d2e21b52d485c48ac8db
BLAKE2b-256 checksum
How to use checksums
3c235d366017f1c9b8748489b6e059fb910b7c14f34f9318279f81c613513950
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release files / jec_api-0.1.3-py3-none-any.whl

Download URL jec_api-0.1.3-py3-none-any.whl
Size 42.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0b924c4f29dd77b58eba0685c7f175a065e19863d66b4a8d44bcdbe64c32d03
BLAKE2b-256 checksum
How to use checksums
5d083642324506719336bf36e97962208c31e156520b8d0af2d1f4897cc9bc62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3
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