apis — REST API Server
- Source:
buem/apis/
Purpose
Expose BuEM as a Flask REST API for external systems. The server is typically run behind Gunicorn inside a Docker container.
Endpoints
Method |
Route |
Description |
|---|---|---|
POST |
|
Run the thermal model for a single building configuration (JSON). Returns heating/cooling summary ± full timeseries. |
POST |
|
Process a GeoJSON FeatureCollection through the batch pipeline
( |
GET |
|
Download a result file (timeseries JSON). Paths are sanitised to prevent directory traversal. |
GET |
|
Health check — returns status, version, timestamp. |
Query parameters (/api/run, /api/process):
include_timeseries(bool) — attach hourly arrays to the responseuse_milp(bool) — use the experimental MILP solver path
Files
- api_server.py
create_app()— Flask application factory. Registers blueprintsmodel_bpandfiles_bp, configures rotating log handler (5 MB, 3 backups).- model_api.py
/api/runand/api/processimplementations. Validates payload viaCfgBuilding→validate_cfg(), runs model, optionally forwards results to an external URL.- files_api.py
/api/files/<filename>— wrapssend_from_directory()with filename sanitisation. Result directory is set by theBUEM_RESULTS_DIRenvironment variable.