Is your feature request related to a problem? Please describe.
Mobile clients (e.g. the Ed3n iOS app) add Inputs to Mycodo via the REST API.
When a required Python library is missing, the API currently returns an “unmet dependency” error and instructs users to log into the web UI to install it.
This breaks the mobile workflow and confuses non-technical users.
Describe the solution you’d like
Expose a secure endpoint that mirrors the web UI’s “Install dependencies” routine so apps can trigger the install directly.
📐 Proposed API
| Method |
Path |
Auth |
JSON Body |
Response 200 |
Errors |
POST |
/api/dependencies/install |
Bearer JWT; role admin or install_dependencies |
Provide one: • input_type: "bh1750" • dependency_name: "smbus2" |
{ "job_id": "uuid", "state": "queued" } |
400 bad payload
403 forbidden
409 identical job running
500 internal |
Job status/logs follow the existing /api/jobs/<job_id> pattern.
Security
- Uses existing JWT auth (
flask_jwt_extended); only users with role admin or install_dependencies may call it.
Implementation Notes
- Blueprint:
mycodo/mycodo_api/routes/dependencies.py
- Helper:
mycodo/utils/dependencies.py
- Uses current
create_background_job infrastructure to run pip install commands and stream logs.
- Mapping of
input_type ➜ package list already lives in mycodo/inputs/REQUIRED_LIBS.
- OpenAPI docstring added so Swagger UI auto-documents the endpoint.
Minimal example
curl -X POST https://<mycodo-host>/api/dependencies/install \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"dependency_name": "smbus2"}'
Is your feature request related to a problem? Please describe.
Mobile clients (e.g. the Ed3n iOS app) add Inputs to Mycodo via the REST API.
When a required Python library is missing, the API currently returns an “unmet dependency” error and instructs users to log into the web UI to install it.
This breaks the mobile workflow and confuses non-technical users.
Describe the solution you’d like
Expose a secure endpoint that mirrors the web UI’s “Install dependencies” routine so apps can trigger the install directly.
📐 Proposed API
POST/api/dependencies/installadminorinstall_dependencies•
input_type:"bh1750"•
dependency_name:"smbus2"{ "job_id": "uuid", "state": "queued" }400bad payload403forbidden409identical job running500internalJob status/logs follow the existing
/api/jobs/<job_id>pattern.Security
flask_jwt_extended); only users with roleadminorinstall_dependenciesmay call it.Implementation Notes
mycodo/mycodo_api/routes/dependencies.pymycodo/utils/dependencies.pycreate_background_jobinfrastructure to runpip installcommands and stream logs.input_type➜ package list already lives inmycodo/inputs/REQUIRED_LIBS.Minimal example