elbow_helper.api module
FastAPI HTTP surface — the web-API door (optional [api] extra).
The third of elbow-helper’s surfaces exposes the pipeline over HTTP so a
service can ask “where’s the knee in this curve?” without a Python import.
FastAPI + uvicorn live behind the [api] extra, imported lazily here so
the core package never pays for a web stack it does not use — the whole
point of the package staying at numpy + os-helper for everyone who
just wants the library. Every endpoint delegates to
elbow_helper._core_cli, so the HTTP behaviour matches the CLI and
library exactly.
Each route carries an explicit operation_id (knee/elbow/
diagnostics/locator) — not just OpenAPI hygiene:
elbow_helper.mcp_server mounts fastapi-mcp on a copy of this same
app and selects exactly these operation ids as the exposed MCP tools, so the
id is the tool name an agent calls. Rename a route here and the MCP door
renames with it, automatically.
Run it with:
pip install 'elbow-helper[api]'
uvicorn elbow_helper.api:app --reload # or: python -m elbow_helper.api
Consumes: fastapi (optional), elbow_helper._core_cli.
Produces: app (the ASGI application), create_app().
- class elbow_helper.api.CurveRequest(*, x, y=None, curve=None, direction=None, config_overrides=None)[source]
Bases:
BaseModelRequest body for
/kneeand/diagnostics: a curve plus knobs.ymay be omitted, mirroringelbow_helper.robust_knee()’s shorthand where a single series is treated as y-values against an implicit0, 1, ..., n-1x axis.- Parameters:
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class elbow_helper.api.DiagnosticsRequest(*, x, y=None, curve=None, direction=None, config_overrides=None, language='en')[source]
Bases:
CurveRequestRequest body for
/diagnostics: a curve plus the SVG’s language.- Parameters:
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class elbow_helper.api.ElbowRequest(*, k, inertia, config_overrides=None)[source]
Bases:
BaseModelRequest body for
/elbow: an explicit x/y pair, both required.- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class elbow_helper.api.LocatorRequest(*, x, y, sensitivity=1.0, curve=None, direction=None, online=True)[source]
Bases:
BaseModelRequest body for
/locator: an explicit x/y pair, no config overrides.- Parameters:
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- elbow_helper.api.create_app()[source]
Build and return the FastAPI application.
- Returns:
The ASGI app with the
/knee,/elbow,/diagnosticsand/locatorroutes wired to the shared core.- Return type:
FastAPI
Examples
>>> app = create_app() >>> [r.path for r in app.routes] ['/openapi.json', '/docs', ..., '/knee', '/elbow', '/diagnostics', '/locator']